コード例 #1
0
 public WurmUnlimitedLogsDirChecker([NotNull] IWurmApi wurmApi, [NotNull] IUserNotifier userNotifier,
                                    [NotNull] IWurmAssistantConfig wurmAssistantConfig)
 {
     this.wurmPaths           = wurmApi.Paths ?? throw new ArgumentNullException(nameof(wurmPaths));
     this.wurmCharacters      = wurmApi.Characters ?? throw new ArgumentNullException(nameof(wurmCharacters));
     this.userNotifier        = userNotifier ?? throw new ArgumentNullException(nameof(userNotifier));
     this.wurmAssistantConfig = wurmAssistantConfig ?? throw new ArgumentNullException(nameof(wurmAssistantConfig));
 }
コード例 #2
0
 public SmileXamineProcessor(
     [NotNull] GrangerFeature parentModule,
     [NotNull] GrangerContext context,
     [NotNull] PlayerManager playerMan,
     [NotNull] GrangerDebugLogger debugLogger,
     [NotNull] ITrayPopups trayPopups, [NotNull] ILogger logger,
     [NotNull] IWurmAssistantConfig wurmAssistantConfig,
     [NotNull] CreatureColorDefinitions creatureColorDefinitions,
     [NotNull] GrangerSettings grangerSettings)
 {
     if (parentModule == null)
     {
         throw new ArgumentNullException(nameof(parentModule));
     }
     if (context == null)
     {
         throw new ArgumentNullException(nameof(context));
     }
     if (playerMan == null)
     {
         throw new ArgumentNullException(nameof(playerMan));
     }
     if (debugLogger == null)
     {
         throw new ArgumentNullException(nameof(debugLogger));
     }
     if (trayPopups == null)
     {
         throw new ArgumentNullException(nameof(trayPopups));
     }
     if (logger == null)
     {
         throw new ArgumentNullException(nameof(logger));
     }
     if (wurmAssistantConfig == null)
     {
         throw new ArgumentNullException(nameof(wurmAssistantConfig));
     }
     if (creatureColorDefinitions == null)
     {
         throw new ArgumentNullException(nameof(creatureColorDefinitions));
     }
     if (grangerSettings == null)
     {
         throw new ArgumentNullException(nameof(grangerSettings));
     }
     this.debugLogger              = debugLogger;
     this.trayPopups               = trayPopups;
     this.logger                   = logger;
     this.wurmAssistantConfig      = wurmAssistantConfig;
     this.creatureColorDefinitions = creatureColorDefinitions;
     this.parentModule             = parentModule;
     this.context                  = context;
     this.playerMan                = playerMan;
     this.grangerSettings          = grangerSettings;
 }
コード例 #3
0
        private static Func <Ninject.Activation.IContext, IWurmApi> BuildWurmApiFactory(IKernel kernel)
        {
            return(context =>
            {
                IWurmAssistantConfig config = kernel.Get <IWurmAssistantConfig>();
                IWurmApiLoggerFactory loggerFactory = kernel.Get <IWurmApiLoggerFactory>();
                IWurmApiEventMarshaller eventMarshaller = kernel.Get <IWurmApiEventMarshaller>();
                IWurmAssistantDataDirectory wurmAssistantDataDirectory = kernel.Get <IWurmAssistantDataDirectory>();

                if (string.IsNullOrWhiteSpace(config.WurmGameClientInstallDirectory))
                {
                    throw new InvalidOperationException("Unknown path to Wurm Game Client installation folder.");
                }

                IWurmClientInstallDirectory wurmInstallDirectory =
                    new WurmInstallDirectoryOverride(config.WurmGameClientInstallDirectory);
                ServerInfoManager serverInfoManager = kernel.Get <ServerInfoManager>();

                var wurmApiConfig = new WurmApiConfig
                {
                    Platform = Platform.Windows,
                    ClearAllCaches = config.DropAllWurmApiCachesToggle,
                    WurmUnlimitedMode = config.WurmUnlimitedMode
                };
                serverInfoManager.UpdateWurmApiConfigDictionary(wurmApiConfig.ServerInfoMap);

                var wurmApiDataDir =
                    new DirectoryInfo(Path.Combine(wurmAssistantDataDirectory.DirectoryPath, "WurmApi"));

                var wurmApi = AldursLab.WurmApi.WurmApiFactory.Create(
                    new WurmApiCreationOptions()
                {
                    DataDirPath = wurmApiDataDir.FullName,
                    WurmApiLogger = loggerFactory.Create(),
                    WurmApiEventMarshaller = eventMarshaller,
                    WurmClientInstallDirectory = wurmInstallDirectory,
                    WurmApiConfig = wurmApiConfig
                });

                config.DropAllWurmApiCachesToggle = false;

                var validator = new WurmClientValidator(wurmApi, config);
                if (!validator.SkipOnStart)
                {
                    var issues = validator.Validate();
                    if (issues.Any())
                    {
                        validator.ShowSummaryWindow(issues);
                    }
                }

                return wurmApi;
            });
        }
コード例 #4
0
ファイル: OptionsForm.cs プロジェクト: tiba666/WurmAssistant3
        public OptionsForm([NotNull] IWurmAssistantConfig wurmAssistantConfig)
        {
            if (wurmAssistantConfig == null)
            {
                throw new ArgumentNullException(nameof(wurmAssistantConfig));
            }
            this.wurmAssistantConfig = wurmAssistantConfig;
            InitializeComponent();

            checkBoxGatherInsights.Checked = wurmAssistantConfig.AllowInsights;
        }
コード例 #5
0
 public LogsFeedManager(
     [NotNull] GrangerFeature parentModule,
     [NotNull] GrangerContext context,
     [NotNull] IWurmApi wurmApi,
     [NotNull] ILogger logger,
     [NotNull] ITrayPopups trayPopups,
     [NotNull] IWurmAssistantConfig wurmAssistantConfig,
     [NotNull] CreatureColorDefinitions creatureColorDefinitions,
     [NotNull] GrangerSettings grangerSettings,
     [NotNull] ITelemetry telemetry)
 {
     if (parentModule == null)
     {
         throw new ArgumentNullException(nameof(parentModule));
     }
     if (context == null)
     {
         throw new ArgumentNullException(nameof(context));
     }
     if (wurmApi == null)
     {
         throw new ArgumentNullException(nameof(wurmApi));
     }
     if (logger == null)
     {
         throw new ArgumentNullException(nameof(logger));
     }
     if (trayPopups == null)
     {
         throw new ArgumentNullException(nameof(trayPopups));
     }
     if (wurmAssistantConfig == null)
     {
         throw new ArgumentNullException(nameof(wurmAssistantConfig));
     }
     if (creatureColorDefinitions == null)
     {
         throw new ArgumentNullException(nameof(creatureColorDefinitions));
     }
     if (grangerSettings == null)
     {
         throw new ArgumentNullException(nameof(grangerSettings));
     }
     this.parentModule             = parentModule;
     this.context                  = context;
     this.wurmApi                  = wurmApi;
     this.logger                   = logger;
     this.trayPopups               = trayPopups;
     this.wurmAssistantConfig      = wurmAssistantConfig;
     this.creatureColorDefinitions = creatureColorDefinitions;
     this.grangerSettings          = grangerSettings;
     this.telemetry                = telemetry ?? throw new ArgumentNullException(nameof(telemetry));
 }
コード例 #6
0
 public WurmClientValidator([NotNull] IWurmApi wurmApi, [NotNull] IWurmAssistantConfig config)
 {
     if (wurmApi == null)
     {
         throw new ArgumentNullException(nameof(wurmApi));
     }
     if (config == null)
     {
         throw new ArgumentNullException(nameof(config));
     }
     this.wurmApi = wurmApi;
     this.config  = config;
 }
コード例 #7
0
 public WaVersionInfoProvider([NotNull] IWurmAssistantConfig wurmAssistantConfig, [NotNull] IWaVersion waVersion)
 {
     if (wurmAssistantConfig == null)
     {
         throw new ArgumentNullException("wurmAssistantConfig");
     }
     if (waVersion == null)
     {
         throw new ArgumentNullException("waVersion");
     }
     this.wurmAssistantConfig = wurmAssistantConfig;
     this.waVersion           = waVersion;
 }
コード例 #8
0
ファイル: Telemetry.cs プロジェクト: tiba666/WurmAssistant3
        public Telemetry([NotNull] IWurmAssistantConfig wurmAssistantConfig)
        {
            if (wurmAssistantConfig == null)
            {
                throw new ArgumentNullException(nameof(wurmAssistantConfig));
            }
            this.wurmAssistantConfig = wurmAssistantConfig;

            client = new TelemetryClient
            {
                InstrumentationKey = "9813c551-b5b1-48c0-baa5-3e8e47ec9683",
            };
            client.Context.User.Id    = wurmAssistantConfig.InstallationId.ToString();
            client.Context.Session.Id = sessionId.ToString();
        }
コード例 #9
0
        public GrangerFeature(
            [NotNull] ILogger logger,
            [NotNull] IWurmAssistantDataDirectory dataDirectory,
            [NotNull] ISoundManager soundManager,
            [NotNull] ITrayPopups trayPopups,
            [NotNull] IWurmApi wurmApi,
            [NotNull] GrangerSettings grangerSettings,
            [NotNull] DefaultBreedingEvaluatorOptions defaultBreedingEvaluatorOptions,
            [NotNull] IWurmAssistantConfig wurmAssistantConfig,
            [NotNull] ITimerFactory timerFactory,
            [NotNull] CreatureColorDefinitions creatureColorDefinitions,
            [NotNull] GrangerContext grangerContext,
            [NotNull] IFormEditCreatureColorsFactory formEditCreatureColorsFactory,
            [NotNull] ITelemetry telemetry)
        {
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }
            if (dataDirectory == null)
            {
                throw new ArgumentNullException(nameof(dataDirectory));
            }
            if (soundManager == null)
            {
                throw new ArgumentNullException(nameof(soundManager));
            }
            if (trayPopups == null)
            {
                throw new ArgumentNullException(nameof(trayPopups));
            }
            if (wurmApi == null)
            {
                throw new ArgumentNullException(nameof(wurmApi));
            }
            if (grangerSettings == null)
            {
                throw new ArgumentNullException(nameof(grangerSettings));
            }
            if (defaultBreedingEvaluatorOptions == null)
            {
                throw new ArgumentNullException(nameof(defaultBreedingEvaluatorOptions));
            }
            if (wurmAssistantConfig == null)
            {
                throw new ArgumentNullException(nameof(wurmAssistantConfig));
            }
            if (timerFactory == null)
            {
                throw new ArgumentNullException(nameof(timerFactory));
            }
            if (creatureColorDefinitions == null)
            {
                throw new ArgumentNullException(nameof(creatureColorDefinitions));
            }
            if (grangerContext == null)
            {
                throw new ArgumentNullException(nameof(grangerContext));
            }
            if (formEditCreatureColorsFactory == null)
            {
                throw new ArgumentNullException(nameof(formEditCreatureColorsFactory));
            }

            this.logger        = logger;
            this.dataDirectory = dataDirectory;
            this.soundManager  = soundManager;
            this.trayPopups    = trayPopups;

            settings = grangerSettings;
            this.defaultBreedingEvaluatorOptions = defaultBreedingEvaluatorOptions;
            this.creatureColorDefinitions        = creatureColorDefinitions;

            context = grangerContext;
            this.formEditCreatureColorsFactory = formEditCreatureColorsFactory;
            this.telemetry = telemetry ?? throw new ArgumentNullException(nameof(telemetry));

            grangerUi = new FormGrangerMain(this,
                                            settings,
                                            context,
                                            logger,
                                            wurmApi,
                                            defaultBreedingEvaluatorOptions,
                                            creatureColorDefinitions,
                                            formEditCreatureColorsFactory,
                                            telemetry);

            logsFeedMan = new LogsFeedManager(this, context, wurmApi, logger, trayPopups, wurmAssistantConfig, creatureColorDefinitions, grangerSettings, telemetry);
            logsFeedMan.UpdatePlayers(settings.CaptureForPlayers);
            grangerUi.GrangerPlayerListChanged += GrangerUI_Granger_PlayerListChanged;

            updateLoop          = timerFactory.CreateUiThreadTimer();
            updateLoop.Interval = TimeSpan.FromMilliseconds(500);
            updateLoop.Tick    += (sender, args) => Update();
            updateLoop.Start();
        }
コード例 #10
0
        public MainMenuUserControl(
            [NotNull] IProcessStarter processStarter,
            [NotNull] IUserNotifier userNotifier,
            [NotNull] IServersEditorViewFactory serversEditorViewFactory,
            [NotNull] IDebuggingWindowFactory debuggingWindowFactory,
            [NotNull] INewsViewModelFactory newsViewModelFactory,
            [NotNull] IWurmAssistantDataDirectory wurmAssistantDataDirectory,
            [NotNull] IWurmAssistantConfig wurmAssistantConfig,
            [NotNull] IEnvironment environment,
            [NotNull] IWurmClientValidatorFactory wurmClientValidatorFactory,
            [NotNull] ILogger logger,
            [NotNull] IOptionsFormFactory optionsFormFactory,
            [NotNull] IDataBackupsViewModelFactory dataBackupsViewModelFactory,
            [NotNull] IWindowManager windowManager)
        {
            if (processStarter == null)
            {
                throw new ArgumentNullException(nameof(processStarter));
            }
            if (userNotifier == null)
            {
                throw new ArgumentNullException(nameof(userNotifier));
            }
            if (serversEditorViewFactory == null)
            {
                throw new ArgumentNullException(nameof(serversEditorViewFactory));
            }
            if (debuggingWindowFactory == null)
            {
                throw new ArgumentNullException(nameof(debuggingWindowFactory));
            }
            if (newsViewModelFactory == null)
            {
                throw new ArgumentNullException(nameof(newsViewModelFactory));
            }
            if (wurmAssistantDataDirectory == null)
            {
                throw new ArgumentNullException(nameof(wurmAssistantDataDirectory));
            }
            if (wurmAssistantConfig == null)
            {
                throw new ArgumentNullException(nameof(wurmAssistantConfig));
            }
            if (environment == null)
            {
                throw new ArgumentNullException(nameof(environment));
            }
            if (wurmClientValidatorFactory == null)
            {
                throw new ArgumentNullException(nameof(wurmClientValidatorFactory));
            }
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }
            if (optionsFormFactory == null)
            {
                throw new ArgumentNullException(nameof(optionsFormFactory));
            }
            if (dataBackupsViewModelFactory == null)
            {
                throw new ArgumentNullException(nameof(dataBackupsViewModelFactory));
            }
            if (windowManager == null)
            {
                throw new ArgumentNullException(nameof(windowManager));
            }
            this.processStarter             = processStarter;
            this.userNotifier               = userNotifier;
            this.serversEditorViewFactory   = serversEditorViewFactory;
            this.debuggingWindowFactory     = debuggingWindowFactory;
            this.newsViewModelFactory       = newsViewModelFactory;
            this.wurmAssistantDataDirectory = wurmAssistantDataDirectory;
            this.wurmAssistantConfig        = wurmAssistantConfig;
            this.environment = environment;
            this.wurmClientValidatorFactory = wurmClientValidatorFactory;
            this.logger                      = logger;
            this.optionsFormFactory          = optionsFormFactory;
            this.dataBackupsViewModelFactory = dataBackupsViewModelFactory;
            this.windowManager               = windowManager;

            InitializeComponent();

            debugToolStripMenuItem.Visible = false;
#if DEBUG
            debugToolStripMenuItem.Visible = true;
#endif
        }
コード例 #11
0
        public PlayerManager(
            [NotNull] GrangerFeature parentModule,
            [NotNull] GrangerContext context,
            [NotNull] string playerName,
            [NotNull] IWurmApi wurmApi,
            [NotNull] ILogger logger,
            [NotNull] ITrayPopups trayPopups,
            [NotNull] IWurmAssistantConfig wurmAssistantConfig,
            [NotNull] CreatureColorDefinitions creatureColorDefinitions,
            [NotNull] GrangerSettings grangerSettings,
            [NotNull] ITelemetry telemetry)
        {
            if (parentModule == null)
            {
                throw new ArgumentNullException(nameof(parentModule));
            }
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (playerName == null)
            {
                throw new ArgumentNullException(nameof(playerName));
            }
            if (wurmApi == null)
            {
                throw new ArgumentNullException(nameof(wurmApi));
            }
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }
            if (trayPopups == null)
            {
                throw new ArgumentNullException(nameof(trayPopups));
            }
            if (wurmAssistantConfig == null)
            {
                throw new ArgumentNullException(nameof(wurmAssistantConfig));
            }
            if (creatureColorDefinitions == null)
            {
                throw new ArgumentNullException(nameof(creatureColorDefinitions));
            }
            if (grangerSettings == null)
            {
                throw new ArgumentNullException(nameof(grangerSettings));
            }
            if (telemetry == null)
            {
                throw new ArgumentNullException(nameof(telemetry));
            }
            this.parentModule = parentModule;
            this.wurmApi      = wurmApi;
            this.logger       = logger;
            this.PlayerName   = playerName;

            creatureUpdateManager = new CreatureUpdatesManager(this.parentModule, context, this, trayPopups, logger, wurmAssistantConfig, creatureColorDefinitions, grangerSettings, telemetry);

            wurmApi.LogsMonitor.Subscribe(PlayerName, LogType.Event, OnNewEventLogEvents);

            character = wurmApi.Characters.Get(PlayerName);
            character.LogInOrCurrentServerPotentiallyChanged += CharacterOnLogInOrCurrentServerPotentiallyChanged;
            character.Skills.SkillsChanged += SkillsOnSkillsChanged;

            BeginUpdateSkillInfo();
        }
コード例 #12
0
        public CreatureUpdatesManager(
            [NotNull] GrangerFeature parentModule,
            [NotNull] GrangerContext context,
            [NotNull] PlayerManager playerManager,
            [NotNull] ITrayPopups trayPopups,
            [NotNull] ILogger logger,
            [NotNull] IWurmAssistantConfig wurmAssistantConfig,
            [NotNull] CreatureColorDefinitions creatureColorDefinitions,
            [NotNull] GrangerSettings grangerSettings)
        {
            if (parentModule == null)
            {
                throw new ArgumentNullException(nameof(parentModule));
            }
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (playerManager == null)
            {
                throw new ArgumentNullException(nameof(playerManager));
            }
            if (trayPopups == null)
            {
                throw new ArgumentNullException(nameof(trayPopups));
            }
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }
            if (wurmAssistantConfig == null)
            {
                throw new ArgumentNullException(nameof(wurmAssistantConfig));
            }
            if (creatureColorDefinitions == null)
            {
                throw new ArgumentNullException(nameof(creatureColorDefinitions));
            }
            if (grangerSettings == null)
            {
                throw new ArgumentNullException(nameof(grangerSettings));
            }

            this.parentModule  = parentModule;
            this.context       = context;
            this.playerManager = playerManager;
            this.trayPopups    = trayPopups;
            this.logger        = logger;

            grangerDebug = new GrangerDebugLogger(logger);

            smileXamineProcessor = new SmileXamineProcessor(this.parentModule,
                                                            this.context,
                                                            this.playerManager,
                                                            grangerDebug,
                                                            trayPopups,
                                                            logger,
                                                            wurmAssistantConfig,
                                                            creatureColorDefinitions,
                                                            grangerSettings);
        }
コード例 #13
0
        void ConstructWurmApi(IWurmAssistantConfig config, LoggerFactory loggerFactory, IEventMarshaller eventMarshaller)
        {
            IWurmInstallDirectory wurmInstallDirectory = null;
            if (!string.IsNullOrWhiteSpace(config.WurmGameClientInstallDirectory))
            {
                wurmInstallDirectory = new WurmInstallDirectoryOverride()
                {
                    FullPath = config.WurmGameClientInstallDirectory
                };
            }

            WurmApiConfig wurmApiConfig = null;
            if (config.RunningPlatform != Platform.Unknown)
            {
                wurmApiConfig = new WurmApiConfig {Platform = config.RunningPlatform};
            }

            wurmApi = WurmApiFactory.Create(Path.Combine(config.DataDirectoryFullPath, "WurmApi"),
                loggerFactory.CreateWithGuiThreadMarshaller("WurmApi"),
                eventMarshaller,
                wurmInstallDirectory,
                wurmApiConfig);
            kernel.Bind<IWurmApi>().ToConstant(wurmApi);
        }