示例#1
0
        /*******************
        ** Debug Methods **
        *******************/

        /// <summary>Debug method to temporarily uncomplete all bundles (for the current menu instance).</summary>
        /// <param name="menu">Instance of the golden scroll menu.</param>
        public static void debugTempClearBundles(JunimoNoteMenu menu)
        {
            for (int i = 0; i < menu.bundles.Count; i++)
            {
                menu.bundles[i].complete = false;
            }
        }
示例#2
0
        /// <summary>Draw tooltip for ingredients if cursor is hovering over them.</summary>
        /// <param name="__instance">The instance of the bundle menu.</param>
        /// <param name="b">The sprite batch.</param>
        public static void Postfix_draw(JunimoNoteMenu __instance, SpriteBatch b)
        {
            try
            {
                if (__instance.ingredientList == null || ingredientHoverText == null || ingredientHoverTitle == null)
                {
                    return;
                }

                int x = (int)input.GetCursorPosition().ScreenPixels.X, y = (int)input.GetCursorPosition().ScreenPixels.Y;
                for (int i = 0; i < __instance.ingredientList.Count; i++)
                {
                    if (__instance.ingredientList[i].bounds.Contains(x, y))
                    {
                        if (i >= ingredientHoverText.Length || i >= ingredientHoverTitle.Length)
                        {
                            continue;
                        }

                        IClickableMenu.drawToolTip(b, ingredientHoverText[i], ingredientHoverTitle[i], null);
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                Log("Error in draw: " + e.Message + Environment.NewLine + e.StackTrace);
            }
        }
示例#3
0
        public static bool CheckForMissedRewards_Prefix(
            CommunityCenter __instance)
        {
            try
            {
                Dictionary <int, List <int> > areaNumbersAndBundleNumbers = Reflection.GetField
                                                                            <Dictionary <int, List <int> > >
                                                                                (__instance, "areaToBundleDictionary")
                                                                            .GetValue();

                __instance.missedRewardsChest.Value.items.Clear();

                bool        hasUnclaimedRewards = false;
                List <Item> rewards             = new();
                foreach (KeyValuePair <int, List <int> > areaAndBundles in areaNumbersAndBundleNumbers)
                {
                    int  areaNumber        = areaAndBundles.Key;
                    bool isRewardUnclaimed = areaAndBundles.Value.Any() &&
                                             areaAndBundles.Value
                                             .All(bundleNumber => __instance.bundleRewards.TryGetValue(bundleNumber, out bool isUnclaimed) && isUnclaimed);
                    if (!isRewardUnclaimed || __instance.areasComplete.Count() <= areaNumber || !__instance.areasComplete[areaNumber])
                    {
                        continue;
                    }

                    hasUnclaimedRewards = true;
                    rewards.Clear();
                    JunimoNoteMenu.GetBundleRewards(areaNumber, rewards);
                    foreach (Item item in rewards)
                    {
                        __instance.missedRewardsChest.Value.addItem(item);
                    }
                }

                if ((hasUnclaimedRewards && !__instance.missedRewardsChestVisible.Value) ||
                    (!hasUnclaimedRewards && __instance.missedRewardsChestVisible.Value))
                {
                    if (!hasUnclaimedRewards)
                    {
                        Vector2 missedRewardsChestTile = Reflection.GetField
                                                         <Vector2>
                                                             (obj: __instance, name: "missedRewardsChestTile")
                                                         .GetValue();

                        Bundles.BroadcastPuffSprites(
                            multiplayer: null,
                            location: __instance,
                            tilePosition: missedRewardsChestTile);
                    }
                }
                __instance.showMissedRewardsChestEvent.Fire(arg: hasUnclaimedRewards);
                __instance.missedRewardsChestVisible.Value = hasUnclaimedRewards;
                return(false);
            }
            catch (Exception e)
            {
                HarmonyPatches.ErrorHandler(e);
            }
            return(true);
        }
示例#4
0
 public void completionAnimation(JunimoNoteMenu menu, bool playSound = true, int delay = 0)
 {
     if (delay <= 0)
     {
         this.completionAnimation(playSound);
         return;
     }
     this.completionTimer = delay;
 }
        /// <summary>
        /// Fixes the ability to highlight rings in the bundle menu
        /// </summary>
        public static void FixRingSelection(object sender, MenuChangedEventArgs e)
        {
            if (!Globals.Config.RandomizeBundles || !(e.NewMenu is JunimoNoteMenu))
            {
                _currentActiveBundleMenu = null;
                return;
            }

            _currentActiveBundleMenu = (JunimoNoteMenu)e.NewMenu;
            _currentActiveBundleMenu.inventory.highlightMethod = HighlightBundleCompatibleItems;
        }
示例#6
0
 public void completionAnimation(JunimoNoteMenu menu, bool playSound = true, int delay = 0)
 {
     if (delay <= 0)
     {
         completionAnimation(playSound);
     }
     else
     {
         completionTimer = delay;
     }
 }
示例#7
0
        /********************
        ** Method Patches **
        ********************/

        /// <summary>After setUpBundleSpecificPage runs, define hover text for ingredients and blank out the originals.</summary>
        /// <param name="__instance">The instance of the bundle menu.</param>
        /// <param name="b">The bundle object.</param>
        public static void Postfix_setUpBundleSpecificPage(JunimoNoteMenu __instance, Bundle b)
        {
            try
            {
                if (__instance.ingredientList == null)
                {
                    return;
                }

                if (debugClearCompletedBundles)
                {
                    debugTempClearBundles(__instance);
                }
                if (debugUnlockMissingBundle)
                {
                    debugUnlockMissing();
                }

                ingredientHoverTitle = new string[__instance.ingredientList.Count];
                ingredientHoverText  = new string[__instance.ingredientList.Count];

                for (int i = 0; i < __instance.ingredientList.Count; i++)
                {
                    try
                    {
                        BundleIngredientDescription ingredient = b.ingredients[i];
                        string hintText = ItemHints.getHintText(ingredient.index, ingredient.quality);
                        if (hintText != "")
                        {
                            ingredientHoverTitle[i] = __instance.ingredientList[i].hoverText;
                            ingredientHoverText[i]  = hintText;
                            __instance.ingredientList[i].hoverText = "";
                        }
                        else
                        {
                            ingredientHoverTitle[i] = "";
                            ingredientHoverText[i]  = "";
                        }
                    }
                    catch (Exception e)
                    {
                        Log("Error defining hint text: " + e.Message + Environment.NewLine + e.StackTrace);
                    }
                }
            }
            catch (Exception e)
            {
                Log("Error in setUpBundleSpecificPage: " + e.Message + Environment.NewLine + e.StackTrace);
            }
        }
示例#8
0
        public static void JunimoNoteMenu_ctor_Postfix(
            JunimoNoteMenu __instance,
            bool fromGameMenu,
            int area,
            bool fromThisMenu)
        {
            CommunityCenter cc = Bundles.CC;

            if (Bundles.IsAbandonedJojaMartBundleAvailableOrComplete())
            {
                return;
            }

            IReflectedField <int> whichAreaField = Reflection.GetField
                                                   <int>
                                                       (__instance, "whichArea");

            bool isAreaSet       = false;
            bool isNavigationSet = false;

            foreach (string areaName in Bundles.GetAllAreaNames())
            {
                int areaNumber = CommunityCenter.getAreaNumberFromName(areaName);

                // Set default area for menu view with custom areas
                if (!isAreaSet &&
                    fromGameMenu && !fromThisMenu && !isAreaSet &&
                    cc.shouldNoteAppearInArea(areaNumber) && !Bundles.IsAreaComplete(cc: cc, areaNumber: areaNumber))
                {
                    area = areaNumber;
                    whichAreaField.SetValue(area);
                    isAreaSet = true;
                }

                // Show navigation arrows when custom areas
                if (!isNavigationSet &&
                    areaNumber >= 0 && areaNumber != area && cc.shouldNoteAppearInArea(areaNumber))
                {
                    __instance.areaNextButton.visible = true;
                    __instance.areaBackButton.visible = true;
                    isNavigationSet = true;
                }

                if (isAreaSet && isNavigationSet)
                {
                    break;
                }
            }
        }
示例#9
0
 private void OnMenuChanged(object sender, MenuChangedEventArgs e)
 {
     if (e.NewMenu is JunimoNoteMenu menu)
     {
         this.ActiveMenu = menu;
         this.Helper.Events.Display.RenderedActiveMenu += this.OnRenderMenu;
         this.Helper.Events.GameLoop.UpdateTicked      += this.OnUpdated;
     }
     else if (e.OldMenu is JunimoNoteMenu)
     {
         this.ActiveMenu = null;
         this.Helper.Events.Display.RenderedActiveMenu -= this.OnRenderMenu;
         this.Helper.Events.GameLoop.UpdateTicked      -= this.OnUpdated;
     }
 }
示例#10
0
        public static void SetUpMenu_Postfix(
            JunimoNoteMenu __instance)
        {
            // Add bundle display names for default locale
            var bundleDisplayNames = Game1.content.Load
                                     <Dictionary <string, string> >
                                         (@"Strings/BundleNames");

            for (int i = 0; i < __instance.bundles.Count; ++i)
            {
                if (Bundles.IsCustomBundle(Bundles.GetBundleNumberFromName(__instance.bundles[i].name)))
                {
                    __instance.bundles[i].label = bundleDisplayNames[__instance.bundles[i].name];
                }
            }
        }
示例#11
0
        public static void GetRewardNameForArea_Postfix(
            JunimoNoteMenu __instance,
            int whichArea,
            ref string __result)
        {
            CustomCommunityCentre.Data.BundleMetadata bundleMetadata = Bundles.GetCustomBundleMetadataFromAreaNumber(whichArea);

            if (Bundles.IsAbandonedJojaMartBundleAvailableOrComplete() || bundleMetadata == null)
            {
                return;
            }

            __result = CustomCommunityCentre.Data.BundleMetadata.GetLocalisedString(
                dict: bundleMetadata.AreaRewardMessage,
                defaultValue: "???");
        }
示例#12
0
 public Item tryToDepositThisItem(Item item, ClickableTextureComponent slot, string noteTextureName)
 {
     if (!depositsAllowed)
     {
         if (Game1.player.hasCompletedCommunityCenter())
         {
             Game1.showRedMessage(Game1.content.LoadString("Strings\\UI:JunimoNote_MustBeAtAJM"));
         }
         else
         {
             Game1.showRedMessage(Game1.content.LoadString("Strings\\UI:JunimoNote_MustBeAtCC"));
         }
         return(item);
     }
     if (!(item is Object) || item is Furniture)
     {
         return(item);
     }
     for (int i = 0; i < ingredients.Count; i++)
     {
         if (IsValidItemForThisIngredientDescription(item, ingredients[i]) && slot.item == null)
         {
             item.Stack    -= ingredients[i].stack;
             ingredients[i] = new BundleIngredientDescription(ingredients[i].index, ingredients[i].stack, ingredients[i].quality, completed: true);
             ingredientDepositAnimation(slot, noteTextureName);
             int index = ingredients[i].index;
             if (index < 0)
             {
                 index = JunimoNoteMenu.GetObjectOrCategoryIndex(index);
             }
             slot.item = new Object(index, ingredients[i].stack, isRecipe: false, -1, ingredients[i].quality);
             Game1.playSound("newArtifact");
             (Game1.getLocationFromName("CommunityCenter") as CommunityCenter).bundles.FieldDict[bundleIndex][i] = true;
             slot.sourceRect.X = 512;
             slot.sourceRect.Y = 244;
             Game1.multiplayer.globalChatInfoMessage("BundleDonate", Game1.player.displayName, slot.item.DisplayName);
             break;
         }
     }
     if (item.Stack > 0)
     {
         return(item);
     }
     return(null);
 }
示例#13
0
        private void Events_UpdateTick(object sender, EventArgs e)
        {
            if (!Game1.hasLoadedGame || Game1.player == null || Game1.activeClickableMenu == null)
            {
                return;
            }

            if (Game1.activeClickableMenu is JunimoNoteMenu)
            {
                JunimoNoteMenu menu = (JunimoNoteMenu)Game1.activeClickableMenu;
                foreach (Bundle b in menu.bundles)
                {
                    if (!neededItems.ContainsKey(b.bundleIndex))
                    {
                        neededItems.Add(b.bundleIndex, new Dictionary <int, object>());
                    }

                    foreach (BundleIngredientDescription ingredient in b.ingredients)
                    {
                        if (ingredient.completed)
                        {
                            neededItems[b.bundleIndex].Remove(ingredient.index);
                            continue;
                        }

                        if (ingredient.index != -1 && !neededItems[b.bundleIndex].ContainsKey(ingredient.index))
                        {
                            neededItems[b.bundleIndex].Add(ingredient.index, null);
                        }

                        foreach (Item item in Game1.player.items)
                        {
                            if (item != null)
                            {
                                if (item.parentSheetIndex == ingredient.index)
                                {
                                    b.shake(0.4f);
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
示例#14
0
        private void GameEvents_QuarterSecondTick(object sender, EventArgs e)
        {
            if (!Game1.hasLoadedGame || Game1.activeClickableMenu == null)
            {
                return;
            }

            if (Game1.activeClickableMenu is JunimoNoteMenu)
            {
                JunimoNoteMenu v = (JunimoNoteMenu)Game1.activeClickableMenu;

                List <Bundle> bndl = new List <Bundle>(v.GetType().GetBaseFieldValue <List <Bundle> >(v, "bundles"));

                foreach (Bundle b in bndl)
                {
                    if (!b.depositsAllowed)
                    {
                        b.depositsAllowed = true;
                    }
                }
            }
        }
示例#15
0
        /// <summary>gameWindowSizeChanged resets hover text for ingredients, so blank it again after it runs.</summary>
        /// <param name="__instance">The instance of the bundle menu.</param>
        public static void Postfix_gameWindowSizeChanged(JunimoNoteMenu __instance)
        {
            try
            {
                if (__instance.ingredientList == null)
                {
                    return;
                }

                for (int i = 0; i < __instance.ingredientList.Count; i++)
                {
                    if (i < ingredientHoverTitle.Length && ingredientHoverTitle[i] != "")
                    {
                        __instance.ingredientList[i].hoverText = "";
                    }
                }
            }
            catch (Exception e)
            {
                Log("Error in gameWindowSizeChanged: " + e.Message + Environment.NewLine + e.StackTrace);
            }
        }
示例#16
0
        public Bundle(int bundleIndex, string rawBundleInfo, bool[] completedIngredientsList, Point position, Texture2D texture, JunimoNoteMenu menu)
            : base(new Rectangle(position.X, position.Y, Game1.tileSize, Game1.tileSize), "")
        {
            if (menu.fromGameMenu)
            {
                this.depositsAllowed = false;
            }
            this.bundleIndex = bundleIndex;
            string[] strArray1 = rawBundleInfo.Split('/');
            this.name  = strArray1[0];
            this.label = strArray1[0];
            if (LocalizedContentManager.CurrentLanguageCode != LocalizedContentManager.LanguageCode.en)
            {
                this.label = strArray1[strArray1.Length - 1];
            }
            this.rewardDescription = strArray1[1];
            string[] strArray2 = strArray1[2].Split(' ');
            this.complete    = true;
            this.ingredients = new List <BundleIngredientDescription>();
            int num1  = 0;
            int index = 0;

            while (index < strArray2.Length)
            {
                this.ingredients.Add(new BundleIngredientDescription(Convert.ToInt32(strArray2[index]), Convert.ToInt32(strArray2[index + 1]), Convert.ToInt32(strArray2[index + 2]), completedIngredientsList[index / 3]));
                if (!completedIngredientsList[index / 3])
                {
                    this.complete = false;
                }
                else
                {
                    ++num1;
                }
                index += 3;
            }
            this.bundleColor = Convert.ToInt32(strArray1[3]);
            int num2 = 4;

            if (LocalizedContentManager.CurrentLanguageCode != LocalizedContentManager.LanguageCode.en)
            {
                num2 = 5;
            }
            this.numberOfIngredientSlots = strArray1.Length > num2?Convert.ToInt32(strArray1[4]) : this.ingredients.Count <BundleIngredientDescription>();

            if (num1 >= this.numberOfIngredientSlots)
            {
                this.complete = true;
            }
            this.sprite = new TemporaryAnimatedSprite(texture, new Rectangle(this.bundleColor * 256 % 512, 244 + this.bundleColor * 256 / 512 * 16, 16, 16), 70f, 3, 99999, new Vector2((float)this.bounds.X, (float)this.bounds.Y), false, false, 0.8f, 0.0f, Color.White, (float)Game1.pixelZoom, 0.0f, 0.0f, 0.0f, false)
            {
                pingPong = true
            };
            this.sprite.paused        = true;
            this.sprite.sourceRect.X += this.sprite.sourceRect.Width;
            if (this.name.ToLower().Contains(Game1.currentSeason) && !this.complete)
            {
                this.shake(3f * (float)Math.PI / 128f);
            }
            if (!this.complete)
            {
                return;
            }
            this.completionAnimation(menu, false, 0);
        }
示例#17
0
        private static void JunimoNoteCustomButtons(JunimoNoteMenu __instance, Bundle ___currentPageBundle, int signal, bool isLeftShiftPressed = false)
        {
            try
            {
                switch (signal)
                {
                case 0:     // For ingredient list
                {
                    if (___currentPageBundle.ingredients.Count >= 0)
                    {
                        currentIngredientListItem = currentIngredientListItem + (isLeftShiftPressed ? -1 : 1);
                        if (currentIngredientListItem >= ___currentPageBundle.ingredients.Count)
                        {
                            if (isLeftShiftPressed)
                            {
                                currentIngredientListItem = ___currentPageBundle.ingredients.Count - 1;
                            }
                            else
                            {
                                currentIngredientListItem = 0;
                            }
                        }

                        if (currentIngredientListItem < 0)
                        {
                            if (isLeftShiftPressed)
                            {
                                currentIngredientListItem = ___currentPageBundle.ingredients.Count - 1;
                            }
                            else
                            {
                                currentIngredientListItem = 0;
                            }
                        }

                        ClickableTextureComponent   c          = __instance.ingredientList[currentIngredientListItem];
                        BundleIngredientDescription ingredient = ___currentPageBundle.ingredients[currentIngredientListItem];

                        Item item      = new StardewValley.Object(ingredient.index, ingredient.stack, isRecipe: false, -1, ingredient.quality);
                        bool completed = false;
                        if (___currentPageBundle != null && ___currentPageBundle.ingredients != null && currentIngredientListItem < ___currentPageBundle.ingredients.Count && ___currentPageBundle.ingredients[currentIngredientListItem].completed)
                        {
                            completed = true;
                        }

                        string toSpeak = item.DisplayName;

                        if (!completed)
                        {
                            int quality = ingredient.quality;
                            if (quality == 1)
                            {
                                toSpeak = $"Silver quality {toSpeak}";
                            }
                            else if (quality == 2 || quality == 3)
                            {
                                toSpeak = $"Gold quality {toSpeak}";
                            }
                            else if (quality >= 4)
                            {
                                toSpeak = $"Iridium quality {toSpeak}";
                            }

                            toSpeak = $"{ingredient.stack} {toSpeak}";
                        }

                        if (completed)
                        {
                            toSpeak = $"Completed {toSpeak}";
                        }

                        c.snapMouseCursorToCenter();
                        MainClass.ScreenReader.Say(toSpeak, true);
                    }
                }
                break;

                case 1:     // For input slot list
                {
                    if (__instance.ingredientSlots.Count >= 0)
                    {
                        currentIngredientInputSlot = currentIngredientInputSlot + (isLeftShiftPressed ? -1 : 1);
                        if (currentIngredientInputSlot >= __instance.ingredientSlots.Count)
                        {
                            if (isLeftShiftPressed)
                            {
                                currentIngredientInputSlot = __instance.ingredientSlots.Count - 1;
                            }
                            else
                            {
                                currentIngredientInputSlot = 0;
                            }
                        }

                        if (currentIngredientInputSlot < 0)
                        {
                            if (isLeftShiftPressed)
                            {
                                currentIngredientInputSlot = __instance.ingredientSlots.Count - 1;
                            }
                            else
                            {
                                currentIngredientInputSlot = 0;
                            }
                        }

                        ClickableTextureComponent c = __instance.ingredientSlots[currentIngredientInputSlot];
                        Item   item = c.item;
                        string toSpeak;

                        if (item == null)
                        {
                            toSpeak = $"Input Slot {currentIngredientInputSlot + 1}";
                        }
                        else
                        {
                            toSpeak = item.DisplayName;
                        }

                        c.snapMouseCursorToCenter();
                        MainClass.ScreenReader.Say(toSpeak, true);
                    }
                }
                break;

                case 2:     // For inventory slots
                {
                    if (__instance.inventory != null && __instance.inventory.actualInventory.Count >= 0)
                    {
                        int prevSlotIndex = currentInventorySlot;
                        currentInventorySlot = currentInventorySlot + (isLeftShiftPressed ? -1 : 1);
                        if (currentInventorySlot >= __instance.inventory.actualInventory.Count)
                        {
                            if (isLeftShiftPressed)
                            {
                                currentInventorySlot = __instance.inventory.actualInventory.Count - 1;
                            }
                            else
                            {
                                currentInventorySlot = 0;
                            }
                        }

                        if (currentInventorySlot < 0)
                        {
                            if (isLeftShiftPressed)
                            {
                                currentInventorySlot = __instance.inventory.actualInventory.Count - 1;
                            }
                            else
                            {
                                currentInventorySlot = 0;
                            }
                        }

                        Item item            = __instance.inventory.actualInventory[currentInventorySlot];
                        ClickableComponent c = __instance.inventory.inventory[currentInventorySlot];
                        string             toSpeak;
                        if (item != null)
                        {
                            toSpeak = item.DisplayName;

                            if ((item as StardewValley.Object) != null)
                            {
                                int quality = ((StardewValley.Object)item).Quality;
                                if (quality == 1)
                                {
                                    toSpeak = $"Silver quality {toSpeak}";
                                }
                                else if (quality == 2 || quality == 3)
                                {
                                    toSpeak = $"Gold quality {toSpeak}";
                                }
                                else if (quality >= 4)
                                {
                                    toSpeak = $"Iridium quality {toSpeak}";
                                }
                            }
                            toSpeak = $"{item.Stack} {toSpeak}";
                        }
                        else
                        {
                            toSpeak = "Empty Slot";
                        }
                        c.snapMouseCursorToCenter();
                        MainClass.ScreenReader.Say(toSpeak, true);
                    }
                }
                break;
                }
            }
            catch (Exception e)
            {
                MainClass.ErrorLog($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}");
            }
        }
示例#18
0
        internal static void JunimoNoteMenuPatch(JunimoNoteMenu __instance, bool ___specificBundlePage, int ___whichArea, Bundle ___currentPageBundle)
        {
            try
            {
                int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position
                if (!___specificBundlePage)
                {
                    currentIngredientListItem = -1;
                    isUsingCustomButtons      = false;

                    string areaName = __instance.scrambledText ? CommunityCenter.getAreaEnglishDisplayNameFromNumber(___whichArea) : CommunityCenter.getAreaDisplayNameFromNumber(___whichArea);
                    string reward   = __instance.getRewardNameForArea(___whichArea);

                    if (__instance.scrambledText)
                    {
                        string toSpeak = "Scrambled Text";
                        if (junimoNoteMenuQuery != toSpeak)
                        {
                            junimoNoteMenuQuery = toSpeak;
                            MainClass.ScreenReader.Say(toSpeak, true);
                        }
                        return;
                    }

                    if (currentJunimoArea != areaName)
                    {
                        currentJunimoArea = areaName;
                        MainClass.DebugLog(areaName);
                        MainClass.ScreenReader.Say($"Area {areaName}, {reward}", true);
                        return;
                    }

                    for (int i = 0; i < __instance.bundles.Count; i++)
                    {
                        if (__instance.bundles[i].containsPoint(x, y))
                        {
                            string toSpeak = $"{__instance.bundles[i].name} bundle";
                            if (junimoNoteMenuQuery != toSpeak)
                            {
                                junimoNoteMenuQuery = toSpeak;
                                MainClass.ScreenReader.Say(toSpeak, true);
                            }
                            return;
                        }
                    }
                    if (__instance.presentButton != null && __instance.presentButton.containsPoint(x, y))
                    {
                        string toSpeak = "Present Button";
                        if (junimoNoteMenuQuery != toSpeak)
                        {
                            junimoNoteMenuQuery = toSpeak;
                            MainClass.ScreenReader.Say(toSpeak, true);
                        }
                        return;
                    }
                    if (__instance.fromGameMenu)
                    {
                        if (__instance.areaNextButton.visible && __instance.areaNextButton.containsPoint(x, y))
                        {
                            string toSpeak = "Next Area Button";
                            if (junimoNoteMenuQuery != toSpeak)
                            {
                                junimoNoteMenuQuery = toSpeak;
                                MainClass.ScreenReader.Say(toSpeak, true);
                            }
                            return;
                        }
                        if (__instance.areaBackButton.visible && __instance.areaBackButton.containsPoint(x, y))
                        {
                            string toSpeak = "Previous Area Button";
                            if (junimoNoteMenuQuery != toSpeak)
                            {
                                junimoNoteMenuQuery = toSpeak;
                                MainClass.ScreenReader.Say(toSpeak, true);
                            }
                            return;
                        }
                    }
                }
                else
                {
                    bool isIPressed         = MainClass.Config.BundleMenuIngredientsInputSlotKey.JustPressed(); // For the ingredients
                    bool isCPressed         = MainClass.Config.BundleMenuInventoryItemsKey.JustPressed();       // For the items in inventory
                    bool isPPressed         = MainClass.Config.BundleMenuPurchaseButtonKey.JustPressed();       // For the Purchase Button
                    bool isVPressed         = MainClass.Config.BundleMenuIngredientsInputSlotKey.JustPressed(); // For the ingredient input slots
                    bool isBackPressed      = MainClass.Config.BundleMenuBackButtonKey.JustPressed();           // For the back button
                    bool isLeftShiftPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftShift);

                    if (isIPressed && !isUsingCustomButtons)
                    {
                        isUsingCustomButtons = true;
                        JunimoNoteCustomButtons(__instance, ___currentPageBundle, 0, isLeftShiftPressed);
                        Task.Delay(200).ContinueWith(_ => { isUsingCustomButtons = false; });
                    }
                    else if (isVPressed && !isUsingCustomButtons)
                    {
                        isUsingCustomButtons = true;
                        JunimoNoteCustomButtons(__instance, ___currentPageBundle, 1, isLeftShiftPressed);
                        Task.Delay(200).ContinueWith(_ => { isUsingCustomButtons = false; });
                    }
                    else if (isCPressed && !isUsingCustomButtons)
                    {
                        isUsingCustomButtons = true;
                        JunimoNoteCustomButtons(__instance, ___currentPageBundle, 2, isLeftShiftPressed);
                        Task.Delay(200).ContinueWith(_ => { isUsingCustomButtons = false; });
                    }
                    else if (isBackPressed && __instance.backButton != null && !__instance.backButton.containsPoint(x, y))
                    {
                        __instance.backButton.snapMouseCursorToCenter();
                        MainClass.ScreenReader.Say("Back Button", true);
                    }
                    else if (isPPressed && __instance.purchaseButton != null && !__instance.purchaseButton.containsPoint(x, y))
                    {
                        __instance.purchaseButton.snapMouseCursorToCenter();
                        MainClass.ScreenReader.Say("Purchase Button", true);
                    }
                }
            }
            catch (Exception e)
            {
                MainClass.ErrorLog($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}");
            }
        }
示例#19
0
 public static void Postfix(JunimoNoteMenu __instance, Bundle b)
 {
     BookcaseEvents.PostBundleSpecificPageSetup.Post(new PostBundleSetupEvent(__instance.ingredientList, __instance.ingredientSlots, __instance.inventory, b));
 }
示例#20
0
        public Bundle(int bundleIndex, string rawBundleInfo, bool[] completedIngredientsList, Point position, Texture2D texture, JunimoNoteMenu menu) : base(new Rectangle(position.X, position.Y, Game1.tileSize, Game1.tileSize), "")
        {
            if (menu.fromGameMenu)
            {
                this.depositsAllowed = false;
            }
            this.bundleIndex = bundleIndex;
            string[] array = rawBundleInfo.Split(new char[]
            {
                '/'
            });
            this.name  = array[0];
            this.label = array[0];
            if (LocalizedContentManager.CurrentLanguageCode != LocalizedContentManager.LanguageCode.en)
            {
                this.label = array[array.Length - 1];
            }
            this.rewardDescription = array[1];
            string[] array2 = array[2].Split(new char[]
            {
                ' '
            });
            this.complete    = true;
            this.ingredients = new List <BundleIngredientDescription>();
            int num = 0;

            for (int i = 0; i < array2.Length; i += 3)
            {
                this.ingredients.Add(new BundleIngredientDescription(Convert.ToInt32(array2[i]), Convert.ToInt32(array2[i + 1]), Convert.ToInt32(array2[i + 2]), completedIngredientsList[i / 3]));
                if (!completedIngredientsList[i / 3])
                {
                    this.complete = false;
                }
                else
                {
                    num++;
                }
            }
            this.bundleColor = Convert.ToInt32(array[3]);
            int num2 = 4;

            if (LocalizedContentManager.CurrentLanguageCode != LocalizedContentManager.LanguageCode.en)
            {
                num2 = 5;
            }
            this.numberOfIngredientSlots = ((array.Length > num2) ? Convert.ToInt32(array[4]) : this.ingredients.Count <BundleIngredientDescription>());
            if (num >= this.numberOfIngredientSlots)
            {
                this.complete = true;
            }
            this.sprite = new TemporaryAnimatedSprite(texture, new Rectangle(this.bundleColor * 256 % 512, 244 + this.bundleColor * 256 / 512 * 16, 16, 16), 70f, 3, 99999, new Vector2((float)this.bounds.X, (float)this.bounds.Y), false, false, 0.8f, 0f, Color.White, (float)Game1.pixelZoom, 0f, 0f, 0f, false)
            {
                pingPong = true
            };
            this.sprite.paused = true;
            TemporaryAnimatedSprite expr_20A_cp_0_cp_0 = this.sprite;

            expr_20A_cp_0_cp_0.sourceRect.X = expr_20A_cp_0_cp_0.sourceRect.X + this.sprite.sourceRect.Width;
            if (this.name.ToLower().Contains(Game1.currentSeason) && !this.complete)
            {
                this.shake(0.07363108f);
            }
            if (this.complete)
            {
                this.completionAnimation(menu, false, 0);
            }
        }
示例#21
0
        public Bundle(int bundleIndex, string rawBundleInfo, bool[] completedIngredientsList, Point position, string textureName, JunimoNoteMenu menu)
            : base(new Rectangle(position.X, position.Y, 64, 64), "")
        {
            if (menu.fromGameMenu)
            {
                depositsAllowed = false;
            }
            this.bundleIndex = bundleIndex;
            string[] split = rawBundleInfo.Split('/');
            name  = split[0];
            label = split[0];
            if (LocalizedContentManager.CurrentLanguageCode != 0)
            {
                label = split[split.Length - 1];
            }
            rewardDescription = split[1];
            if (split.Length > 5 && (LocalizedContentManager.CurrentLanguageCode == LocalizedContentManager.LanguageCode.en || split.Length > 6))
            {
                string bundle_image_override = split[5];
                try
                {
                    if (bundle_image_override.IndexOf(':') >= 0)
                    {
                        string[] bundle_image_parts = bundle_image_override.Split(':');
                        bundleTextureOverride      = Game1.content.Load <Texture2D>(bundle_image_parts[0]);
                        bundleTextureIndexOverride = int.Parse(bundle_image_parts[1]);
                    }
                    else
                    {
                        bundleTextureIndexOverride = int.Parse(bundle_image_override);
                    }
                }
                catch (Exception)
                {
                    bundleTextureOverride      = null;
                    bundleTextureIndexOverride = -1;
                }
            }
            string[] ingredientsSplit = split[2].Split(' ');
            complete    = true;
            ingredients = new List <BundleIngredientDescription>();
            int tally = 0;

            for (int i = 0; i < ingredientsSplit.Length; i += 3)
            {
                ingredients.Add(new BundleIngredientDescription(Convert.ToInt32(ingredientsSplit[i]), Convert.ToInt32(ingredientsSplit[i + 1]), Convert.ToInt32(ingredientsSplit[i + 2]), completedIngredientsList[i / 3]));
                if (!completedIngredientsList[i / 3])
                {
                    complete = false;
                }
                else
                {
                    tally++;
                }
            }
            bundleColor = Convert.ToInt32(split[3]);
            int count = 4;

            if (LocalizedContentManager.CurrentLanguageCode != 0)
            {
                count = 5;
            }
            numberOfIngredientSlots = ((split.Length > count) ? Convert.ToInt32(split[4]) : ingredients.Count());
            if (tally >= numberOfIngredientSlots)
            {
                complete = true;
            }
            sprite = new TemporaryAnimatedSprite(textureName, new Rectangle(bundleColor * 256 % 512, 244 + bundleColor * 256 / 512 * 16, 16, 16), 70f, 3, 99999, new Vector2(bounds.X, bounds.Y), flicker: false, flipped: false, 0.8f, 0f, Color.White, 4f, 0f, 0f, 0f)
            {
                pingPong = true
            };
            sprite.paused        = true;
            sprite.sourceRect.X += sprite.sourceRect.Width;
            if (name.ToLower().Contains(Game1.currentSeason) && !complete)
            {
                shake();
            }
            if (complete)
            {
                completionAnimation(menu, playSound: false);
            }
        }
        public string GetCurrentBundleName(JunimoNoteMenu menu)
        {
            var bundle = Helper.Reflection.GetField <Bundle>(menu, "currentPageBundle").GetValue();

            return(bundle.label);
        }