public float ZoomLevel => 1.0f; // SMAPI's draw call will handle zoom


        /*********
        ** Public methods
        *********/
        public GiftHelper(GiftHelperType helperType, IGiftDataProvider dataProvider, GiftConfig config, IReflectionHelper reflection, ITranslationHelper translation)
        {
            this.GiftHelperType       = helperType;
            this.GiftConfig           = config;
            this.Reflection           = reflection;
            this.Translation          = translation;
            this.GiftDrawDataProvider = new GiftDrawDataProvider(dataProvider);
        }
        private void LoadGiftHelpers(IModHelper helper)
        {
            Utils.DebugLog("Initializing gift helpers");

            // TODO: add a reload method to the gift helpers instead of fully re-creating them
            // Force the gift info to be rebuilt
            IGiftDataProvider dataProvider = null;

            if (Config.ShowOnlyKnownGifts)
            {
                // The prefix is purely for convenience. Mostly so I know which is which.
                string prefix = new string(Game1.player.Name.Where(char.IsLetterOrDigit).ToArray());
                string path   = this.Config.ShareKnownGiftsWithAllSaves
                    ? Path.Combine(StoredGiftDatabase.DBRoot, StoredGiftDatabase.DBFileName)
                    : Path.Combine(StoredGiftDatabase.DBRoot, $"{prefix}_{Game1.player.UniqueMultiplayerID}", StoredGiftDatabase.DBFileName);

                GiftDatabase = new StoredGiftDatabase(helper, path);

                if (this.ModManifest.Version.IsNewerThan("2.7") && !this.Config.ShareKnownGiftsWithAllSaves)
                {
                    string oldPath     = Path.Combine(StoredGiftDatabase.DBRoot, Constants.SaveFolderName, StoredGiftDatabase.DBFileName);
                    string fullOldPath = Path.Combine(helper.DirectoryPath, oldPath);
                    if (File.Exists(fullOldPath))
                    {
                        Utils.DebugLog($"Found old DB at {oldPath}. Migrating to {path}.", LogLevel.Info);
                        StoredGiftDatabase dbRef = (StoredGiftDatabase)GiftDatabase;
                        StoredGiftDatabase.MigrateDatabase(helper, oldPath, ref dbRef);
                    }
                }

                dataProvider = new ProgressionGiftDataProvider(GiftDatabase);
                ControlEvents.MouseChanged            += CheckGiftGivenAfterMouseChanged;
                ControlEvents.ControllerButtonPressed += CheckGiftGivenAfterControllerButtonPressed;
            }
            else
            {
                GiftDatabase = new GiftDatabase(helper);
                dataProvider = new AllGiftDataProvider(GiftDatabase);
                ControlEvents.MouseChanged            -= CheckGiftGivenAfterMouseChanged;
                ControlEvents.ControllerButtonPressed -= CheckGiftGivenAfterControllerButtonPressed;
            }

            // Add the helpers if they're enabled in config
            CurrentGiftHelper = null;
            this.GiftHelpers  = new Dictionary <Type, IGiftHelper>();
            if (Config.ShowOnCalendar)
            {
                this.GiftHelpers.Add(typeof(Billboard), new CalendarGiftHelper(dataProvider, Config, helper.Reflection, helper.Translation));
            }
            if (Config.ShowOnSocialPage)
            {
                this.GiftHelpers.Add(typeof(GameMenu), new SocialPageGiftHelper(dataProvider, Config, helper.Reflection, helper.Translation));
            }

            MenuEvents.MenuClosed  += OnClickableMenuClosed;
            MenuEvents.MenuChanged += OnClickableMenuChanged;
        }
Example #3
0
        public GiftDrawDataProvider(IGiftDataProvider GiftDataProvider, bool rebuildGiftData = true)
        {
            this.GiftDataProvider = GiftDataProvider;
            this.GiftDataProvider.DataSourceChanged += () => BuildGiftData();

            // Only build once the first time, after that it only needs to be rebuilt
            // if the datasource changes (in progression mode).
            // TODO: this rebuild flag is causing it to be built twice (once for calendar, once for social).
            // It only happens once so it's not a big deal, but if there's a nice way to avoid it that would be better.
            if (NpcGiftInfo == null || rebuildGiftData)
            {
                BuildGiftData();
            }
        }
        private void LoadGiftHelpers(IModHelper helper)
        {
            Utils.DebugLog("Initializing gift helpers");

            // TODO: add a reload method to the gift helpers instead of fully re-creating them
            // Force the gift info to be rebuilt
            IGiftDataProvider dataProvider = null;

            if (Config.ShowOnlyKnownGifts)
            {
                string path = this.Config.ShareKnownGiftsWithAllSaves
                    ? Path.Combine(StoredGiftDatabase.DBRoot, StoredGiftDatabase.DBFileName)
                    : Path.Combine(StoredGiftDatabase.DBRoot, Constants.SaveFolderName, StoredGiftDatabase.DBFileName);

                GiftDatabase = new StoredGiftDatabase(helper, path);
                dataProvider = new ProgressionGiftDataProvider(GiftDatabase);
                ControlEvents.MouseChanged            += CheckGiftGivenAfterMouseChanged;
                ControlEvents.ControllerButtonPressed += CheckGiftGivenAfterControllerButtonPressed;
            }
            else
            {
                GiftDatabase = new GiftDatabase(helper);
                dataProvider = new AllGiftDataProvider(GiftDatabase);
                ControlEvents.MouseChanged            -= CheckGiftGivenAfterMouseChanged;
                ControlEvents.ControllerButtonPressed -= CheckGiftGivenAfterControllerButtonPressed;
            }

            // Add the helpers if they're enabled in config
            CurrentGiftHelper = null;
            this.GiftHelpers  = new Dictionary <Type, IGiftHelper>();
            if (Config.ShowOnCalendar)
            {
                this.GiftHelpers.Add(typeof(Billboard), new CalendarGiftHelper(dataProvider, Config, helper.Reflection, helper.Translation));
            }
            if (Config.ShowOnSocialPage)
            {
                this.GiftHelpers.Add(typeof(GameMenu), new SocialPageGiftHelper(dataProvider, Config, helper.Reflection, helper.Translation));
            }

            MenuEvents.MenuClosed  += OnClickableMenuClosed;
            MenuEvents.MenuChanged += OnClickableMenuChanged;
        }
Example #5
0
 /*********
 ** Public methods
 *********/
 public CalendarGiftHelper(IGiftDataProvider dataProvider, GiftConfig config, IReflectionHelper reflection, ITranslationHelper translation)
     : base(GiftHelperType.Calendar, dataProvider, config, reflection, translation)
 {
 }
 /*********
 ** Public methods
 *********/
 public SocialPageGiftHelper(IGiftDataProvider dataProvider, GiftConfig config, IReflectionHelper reflection, ITranslationHelper translation)
     : base(GiftHelperType.SocialPage, dataProvider, config, reflection, translation)
 {
 }