예제 #1
0
 public override void update(GameTime time)
 {
     base.update(time);
     if (checkListPopulation())
     {
         return;
     }
     if (_deleteTask != null)
     {
         if (_deleteTask.IsCanceled || _deleteTask.IsCompleted || _deleteTask.IsFaulted)
         {
             if (!_deleteTask.IsCompleted)
             {
                 selectedForDelete = -1;
             }
             _deleteTask = null;
             deleting    = false;
         }
         return;
     }
     if (selectedForDelete != -1 && !deleteConfirmationScreen && !deleting)
     {
         SaveFileSlot slot = MenuSlots[selectedForDelete] as SaveFileSlot;
         if (slot != null)
         {
             slot.Farmer.unload();
             MenuSlots.RemoveAt(selectedForDelete);
             selectedForDelete = -1;
             slotButtons.Clear();
             deleteButtons.Clear();
             for (int i = 0; i < 4; i++)
             {
                 slotButtons.Add(new ClickableComponent(new Rectangle(xPositionOnScreen + 16, yPositionOnScreen + 16 + i * (height / 4), width - 32, height / 4 + 4), string.Concat(i)));
                 if (hasDeleteButtons())
                 {
                     deleteButtons.Add(new ClickableTextureComponent("", new Rectangle(xPositionOnScreen + width - 64 - 4, yPositionOnScreen + 32 + 4 + i * (height / 4), 48, 48), "", "Delete File", Game1.mouseCursors, new Rectangle(322, 498, 12, 12), 3f));
                 }
             }
         }
     }
     if (timerToLoad <= 0)
     {
         return;
     }
     timerToLoad -= time.ElapsedGameTime.Milliseconds;
     if (timerToLoad <= 0)
     {
         if (MenuSlots.Count > selected)
         {
             MenuSlots[selected].Activate();
         }
         else
         {
             Game1.ExitToTitle();
         }
     }
 }
        internal static void LoadGameMenuPatch(SaveFileSlot __instance, LoadGameMenu ___menu, int i)
        {
            try
            {
                int x = Game1.getMouseX(true), y = Game1.getMouseY(true);
                if (___menu.slotButtons[i].containsPoint(x, y))
                {
                    if (__instance.Farmer != null)
                    {
                        #region Farms
                        if (___menu.deleteButtons.Count > 0 && ___menu.deleteButtons[i].containsPoint(x, y))
                        {
                            MainClass.ScreenReader.SayWithChecker($"Delete {__instance.Farmer.farmName.Value} Farm", true);
                            return;
                        }

                        if (___menu.deleteConfirmationScreen)
                        {
                            // Used diff. functions to narrate to prevent it from speaking the message again on selecting another button.
                            string message = "Really delete farm?";

                            MainClass.ScreenReader.SayWithChecker(message, true);
                            if (___menu.okDeleteButton.containsPoint(x, y))
                            {
                                MainClass.ScreenReader.SayWithMenuChecker("Ok Button", false);
                            }
                            else if (___menu.cancelDeleteButton.containsPoint(x, y))
                            {
                                MainClass.ScreenReader.SayWithMenuChecker("Cancel Button", false);
                            }
                            return;
                        }

                        String farmerName            = __instance.Farmer.displayName;
                        String farmName              = __instance.Farmer.farmName.Value;
                        String money                 = __instance.Farmer.Money.ToString();
                        String hoursPlayed           = Utility.getHoursMinutesStringFromMilliseconds(__instance.Farmer.millisecondsPlayed);
                        string dateStringForSaveGame = ((!__instance.Farmer.dayOfMonthForSaveGame.HasValue ||
                                                         !__instance.Farmer.seasonForSaveGame.HasValue ||
                                                         !__instance.Farmer.yearForSaveGame.HasValue) ? __instance.Farmer.dateStringForSaveGame : Utility.getDateStringFor(__instance.Farmer.dayOfMonthForSaveGame.Value, __instance.Farmer.seasonForSaveGame.Value, __instance.Farmer.yearForSaveGame.Value));

                        string toSpeak = $"{farmName} Farm Selected, \t\n Farmer:{farmerName}, \t\nMoney:{money}, \t\nHours Played:{hoursPlayed}, \t\nDate:{dateStringForSaveGame}";

                        MainClass.ScreenReader.SayWithChecker(toSpeak, true);
                        #endregion
                    }
                }
            }
            catch (Exception e)
            {
                MainClass.ErrorLog($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}");
            }
        }
예제 #3
0
        private void deleteFile(int which)
        {
            SaveFileSlot slot = MenuSlots[which] as SaveFileSlot;

            if (slot != null)
            {
                string filenameNoTmpString = slot.Farmer.slotName;
                string fullFilePath        = Path.Combine(Path.Combine(Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley"), "Saves"), filenameNoTmpString));
                Thread.Sleep(Game1.random.Next(1000, 5000));
                if (Directory.Exists(fullFilePath))
                {
                    Directory.Delete(fullFilePath, recursive: true);
                }
            }
        }
예제 #4
0
        private void AttemptToCleanSaves(ButtonPressedEventArgs e)
        {
            // Always attempt to clean up the animal types to prevent on save load crashes
            // if the patch mod had been removed without the animals being sold/deleted
            if (Game1.activeClickableMenu is TitleMenu titleMenu && TitleMenu.subMenu is LoadGameMenu loadGameMenu)
            {
                if (loadGameMenu.slotButtons == null)
                {
                    return;
                }

                List <MenuSlot> menuSlots = this.Helper.Reflection.GetField <List <MenuSlot> >(loadGameMenu, "menuSlots").GetValue();

                if (menuSlots == null || !menuSlots.Any())
                {
                    return;
                }

                int x = (int)e.Cursor.ScreenPixels.X;
                int y = (int)e.Cursor.ScreenPixels.Y;

                int currentItemIndex = this.Helper.Reflection.GetField <int>(loadGameMenu, "currentItemIndex").GetValue();

                for (int index = 0; index < loadGameMenu.slotButtons.Count; index++)
                {
                    if (currentItemIndex + index < menuSlots.Count && loadGameMenu.slotButtons[index].containsPoint(x, y))
                    {
                        SaveFileSlot saveFileSlot = menuSlots[currentItemIndex + index] as SaveFileSlot;

                        this.Helper.ConsoleCommands.Trigger("bfav_fa_fix", new string[] { saveFileSlot.Farmer.slotName });

                        break;
                    }
                }
            }
        }