Exemplo n.º 1
0
        public FormHerdMerge(
            [NotNull] GrangerContext context,
            [NotNull] FormGrangerMain mainForm,
            [NotNull] string sourceHerdName,
            [NotNull] ILogger logger)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (mainForm == null)
            {
                throw new ArgumentNullException(nameof(mainForm));
            }
            if (sourceHerdName == null)
            {
                throw new ArgumentNullException(nameof(sourceHerdName));
            }
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }
            this.context        = context;
            this.mainForm       = mainForm;
            this.sourceHerdName = sourceHerdName;
            this.logger         = logger;

            InitializeComponent();

            textBoxFromHerd.Text = this.sourceHerdName;
            comboBoxToHerd.Items.AddRange(
                this.context.Herds.Where(x => x.HerdId != sourceHerdName).Cast <object>().ToArray());
            listBoxFromHerd.Items.AddRange(
                this.context.Creatures.Where(x => x.Herd == this.sourceHerdName).Cast <object>().ToArray());
        }
Exemplo n.º 2
0
        internal void Init(
            [NotNull] FormGrangerMain formGrangerMain,
            [NotNull] GrangerContext context,
            [NotNull] ILogger logger)
        {
            if (formGrangerMain == null)
            {
                throw new ArgumentNullException(nameof(formGrangerMain));
            }
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }
            this.mainForm          = formGrangerMain;
            this.context           = context;
            this.logger            = logger;
            _debugMainFormAssigned = true;

            if (mainForm.Settings.AdjustForDarkThemes)
            {
                MakeDarkHighContrastFriendly();
            }

            if (mainForm.Settings.TraitViewState != null)
            {
                objectListView1.RestoreState(mainForm.Settings.TraitViewState);
            }
            traitViewManager = new TraitViewManager(mainForm, this.context, objectListView1);
        }
Exemplo n.º 3
0
 public Creature(
     FormGrangerMain mainForm,
     CreatureEntity entity,
     GrangerContext context,
     [NotNull] CreatureColorDefinitions creatureColorDefinitions)
 {
     if (creatureColorDefinitions == null)
     {
         throw new ArgumentNullException(nameof(creatureColorDefinitions));
     }
     BreedHintColor = null;
     this.mainForm  = mainForm;
     Entity         = entity;
     this.context   = context;
     this.creatureColorDefinitions = creatureColorDefinitions;
 }
Exemplo n.º 4
0
        public void Init(
            [NotNull] FormGrangerMain mainForm,
            [NotNull] GrangerContext context,
            [NotNull] ILogger logger,
            [NotNull] IWurmApi wurmApi,
            [NotNull] CreatureColorDefinitions creatureColorDefinitions)
        {
            if (mainForm == null)
            {
                throw new ArgumentNullException(nameof(mainForm));
            }
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }
            if (wurmApi == null)
            {
                throw new ArgumentNullException(nameof(wurmApi));
            }
            if (creatureColorDefinitions == null)
            {
                throw new ArgumentNullException(nameof(creatureColorDefinitions));
            }
            this.mainForm = mainForm;
            this.context  = context;
            this.logger   = logger;
            this.wurmApi  = wurmApi;
            this.creatureColorDefinitions = creatureColorDefinitions;

            CustomizeOlv();

            this.context.OnHerdsModified += RefreshHerdList;
            RefreshHerdList(this, EventArgs.Empty);
        }
Exemplo n.º 5
0
        public TraitViewManager(
            [NotNull] FormGrangerMain mainForm,
            [NotNull] GrangerContext context,
            [NotNull] ObjectListView listview)
        {
            if (mainForm == null)
            {
                throw new ArgumentNullException(nameof(mainForm));
            }
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (listview == null)
            {
                throw new ArgumentNullException(nameof(listview));
            }
            this.mainForm = mainForm;
            this.context  = context;
            this.olv      = listview;

            olv.FormatRow += OLV_FormatRow;

            allTraits = CreatureTrait.GetAllTraitEnums().Select(x => new CreatureTrait(x)).ToArray();
            BuildClearTraitView();

            listview.SetObjects(items);
            Decide();

            this.mainForm.GrangerSelectedSingleCreatureChanged += MainFormGrangerSelectedCreaturesChanged;
            this.mainForm.GrangerValuatorChanged             += MainForm_Granger_ValuatorChanged;
            this.mainForm.GrangerTraitViewDisplayModeChanged += MainForm_Granger_TraitViewDisplayModeChanged;
            this.context.OnHerdsModified       += Context_OnHerdsModified;
            this.context.OnCreaturesModified   += ContextOnCreaturesModified;
            this.context.OnTraitValuesModified += Context_OnTraitValuesModified;
        }
Exemplo n.º 6
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();
        }
        public void Init(
            [NotNull] FormGrangerMain mainForm,
            [NotNull] GrangerContext context,
            [NotNull] ILogger logger,
            [NotNull] IWurmApi wurmApi,
            [NotNull] CreatureColorDefinitions creatureColorDefinitons)
        {
            if (mainForm == null)
            {
                throw new ArgumentNullException(nameof(mainForm));
            }
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }
            if (wurmApi == null)
            {
                throw new ArgumentNullException(nameof(wurmApi));
            }
            if (creatureColorDefinitons == null)
            {
                throw new ArgumentNullException(nameof(creatureColorDefinitons));
            }
            this.logger   = logger;
            this.wurmApi  = wurmApi;
            this.mainForm = mainForm;
            this.context  = context;
            this.creatureColorDefinitons = creatureColorDefinitons;

            _debugMainFormAssigned = true;

            if (this.mainForm.Settings.AdjustForDarkThemes)
            {
                MakeDarkHighContrastFriendly();
            }

            if (mainForm.Settings.CreatureListState != null)
            {
                this.objectListView1.RestoreState(mainForm.Settings.CreatureListState);
            }

            SetupOlvCustomizations();

            this.context.OnHerdsModified         += Context_OnHerdsModified;
            this.context.OnCreaturesModified     += ContextOnCreaturesModified;
            this.mainForm.GrangerUserViewChanged += MainForm_UserViewChanged;
            this.mainForm.GrangerAdvisorChanged  += MainForm_Granger_AdvisorChanged;
            this.mainForm.GrangerValuatorChanged += MainForm_Granger_ValuatorChanged;

            creatureColorMenuManager = new CreatureColorMenuManager(setColorToolStripMenuItem,
                                                                    creatureColorDefinitons,
                                                                    SetColorMenuItemClickAction);

            UpdateCurrentCreaturesData();
            UpdateDataForView();
            timer1.Enabled = true;
        }