Пример #1
0
        public static bool AutoSavePatch_remindBlankSaveCount(ref SaveAction __instance)
        {
            Heluo.Logger.LogError("AutoSavePatch_remindBlankSaveCount start");
            UIAutoSave uiautoSave     = Game.UI.Open <UIAutoSave>();
            bool       paginationTemp = pagination.Value;

            pagination.Value = false;
            List <PathOfWuxiaSaveHeader> list = Game.Platform.ListSaveHeaderFile(GameSaveType.Auto);

            pagination.Value = paginationTemp;
            string   format   = "PathOfWuxia_{0:00}.{1}";
            int      num      = -1;
            DateTime saveTime = new DateTime(100L);

            for (int i = 0; i < list.Count; i++)
            {
                PathOfWuxiaSaveHeader pathOfWuxiaSaveHeader = list[i];
                if (!pathOfWuxiaSaveHeader.HasData)
                {
                    num = i;
                    break;
                }
                if (DateTime.Compare(pathOfWuxiaSaveHeader.SaveTime, saveTime) > 0)
                {
                    num      = ((i + 1 > saveCount.Value - 1) ? 0 : (i + 1));               //存档满了不能只覆盖前20个
                    saveTime = pathOfWuxiaSaveHeader.SaveTime;
                }
            }
            string filename = string.Format(format, num, "autosave");

            Game.GameData.AutoSaveTotalTime = Game.GameData.Round.TotalTime;
            Game.SaveAsync(filename, null);
            uiautoSave.Show();
            //提示空白存档剩余数量
            if (remindBlankSaveCount.Value && saveCount.Value - num - 1 <= 5)
            {
                string text = "空白存档数量剩余" + (saveCount.Value - num - 1) + "个,请及时扩容,否则将从头开始覆盖存档";
                Game.UI.OpenMessageWindow(text, null, true);
            }
            Heluo.Logger.LogError("AutoSavePatch_remindBlankSaveCount end");
            return(false);
        }
Пример #2
0
        public static bool ListSaveHeaderFilePatch_changeSaveCount(ref SteamPlatform __instance, ref GameSaveType Type, ref List <PathOfWuxiaSaveHeader> __result)
        {
            Heluo.Logger.LogError("ListSaveHeaderFilePatch_changeSaveCount start");
            List <PathOfWuxiaSaveHeader> list = new List <PathOfWuxiaSaveHeader>();
            string format = (Type == GameSaveType.Auto) ? "PathOfWuxia_{0:00}.autosave" : "PathOfWuxia_{0:00}.save";

            int startIndex = 0;
            int endIndex   = saveCount.Value;

            if (pagination.Value)
            {
                startIndex = (currentPage - 1) * countPerPage.Value;
                endIndex   = Math.Min(currentPage * countPerPage.Value, saveCount.Value);
            }

            Heluo.Logger.LogError("startIndex:" + startIndex);
            Heluo.Logger.LogError("endIndex:" + endIndex);
            for (int i = startIndex; i < endIndex; i++)
            {
                PathOfWuxiaSaveHeader pathOfWuxiaSaveHeader = null;
                string text = string.Format(format, i);
                if (SteamRemoteStorage.FileExists(text))
                {
                    __instance.GetSaveFileHeader(text, ref pathOfWuxiaSaveHeader);
                }
                else
                {
                    pathOfWuxiaSaveHeader = new PathOfWuxiaSaveHeader();
                }
                if (pathOfWuxiaSaveHeader == null)
                {
                    pathOfWuxiaSaveHeader = new PathOfWuxiaSaveHeader();
                }
                list.Add(pathOfWuxiaSaveHeader);
            }

            __result = list;
            Heluo.Logger.LogError("list.count:" + list.Count);
            Heluo.Logger.LogError("ListSaveHeaderFilePatch_changeSaveCount end");
            return(false);
        }
Пример #3
0
        public static void UpdateSaveLoadPatch_jumpToLatestSave(ref CtrlSaveLoad __instance)
        {
            Heluo.Logger.LogError("UpdateSaveLoadPatch_jumpToLatestSave start");
            //每次进来先置1,防止中途关闭分页功能后仍然停留在后续页面
            currentPage = 1;
            if (jumpToLatestSave.Value)
            {
                //判断是存档还是自动存档
                int categoryIndex = Traverse.Create(__instance).Field("categoryIndex").GetValue <int>();

                //先暂时取消分页,获取所有存档,以找到最新的一条,然后恢复
                bool paginationTemp = pagination.Value;
                pagination.Value = false;
                List <PathOfWuxiaSaveHeader> saves;
                if (categoryIndex == 0)
                {
                    saves = Game.Platform.ListSaveHeaderFile(GameSaveType.Manual);
                }
                else
                {
                    saves = Game.Platform.ListSaveHeaderFile(GameSaveType.Auto);
                }
                pagination.Value = paginationTemp;

                //获取最新存档的index
                int      num      = -1;
                DateTime saveTime = new DateTime(100L);

                for (int i = 0; i < saves.Count; i++)
                {
                    PathOfWuxiaSaveHeader pathOfWuxiaSaveHeader = saves[i];
                    if (!pathOfWuxiaSaveHeader.HasData)
                    {
                        continue;
                    }
                    if (DateTime.Compare(pathOfWuxiaSaveHeader.SaveTime, saveTime) > 0)
                    {
                        num      = i;
                        saveTime = pathOfWuxiaSaveHeader.SaveTime;
                    }
                }
                int currentIndex = num;
                int totalIndex   = saveCount.Value;

                //重新给saves和autosaves赋值
                if (pagination.Value)
                {
                    currentPage = (num / countPerPage.Value) + 1;

                    //如果是最后一页,有可能出现存档数不足一页的情况,所以以总数量-前面几页的数量计算
                    if (currentPage == totalPage)
                    {
                        totalIndex = saveCount.Value - (currentPage - 1) * countPerPage.Value;
                    }
                    else
                    {
                        totalIndex = countPerPage.Value;
                    }

                    currentIndex = num % countPerPage.Value;
                }
                Traverse.Create(__instance).Field("saves").SetValue(Game.Platform.ListSaveHeaderFile(GameSaveType.Manual));
                Traverse.Create(__instance).Field("autosaves").SetValue(Game.Platform.ListSaveHeaderFile(GameSaveType.Auto));

                //更新界面
                UISaveLoad view = Traverse.Create(__instance).Field("view").GetValue <UISaveLoad>();
                view.UpdateSaveLoad(totalIndex, true, true);

                //更新分页栏
                WGTabScroll saveload = Traverse.Create(view).Field("saveload").GetValue <WGTabScroll>();
                GameObject  pageBar  = saveload.transform.Find("pageBar").gameObject;
                createPageBar(pageBar, __instance);

                //更新滚动条位置
                WGInfiniteScroll loopScroll = Traverse.Create(saveload).Field("loopScroll").GetValue <WGInfiniteScroll>();
                ScrollRect       scrollRect = Traverse.Create(loopScroll).Field("scrollRect").GetValue <ScrollRect>();
                scrollRect.verticalScrollbar.value = ((float)(totalIndex - currentIndex - 1)) / (totalIndex - 1);              //滑动条是反的,不知道为什么
            }
            Heluo.Logger.LogError("UpdateSaveLoadPatch_jumpToLatestSave end");
        }