Example #1
0
 private void RefreshSlotsFor(MenuLevel level, SaveManagementLevel.SMOperation operation, Func <SaveSlotInfo, bool> condition)
 {
     level.Items.Clear();
     foreach (SaveSlotInfo saveSlotInfo in this.Slots)
     {
         SaveSlotInfo s = saveSlotInfo;
         MenuItem     menuItem;
         if (saveSlotInfo.Empty)
         {
             (menuItem = level.AddItem((string)null, (Action)(() => this.ChooseSaveSlot(s, operation)), -1)).SuffixText = (Func <string>)(() => StaticText.GetString("NewSlot"));
         }
         else
         {
             (menuItem = level.AddItem("SaveSlotPrefix", (Action)(() => this.ChooseSaveSlot(s, operation)), -1)).SuffixText = (Func <string>)(() => string.Format((IFormatProvider)CultureInfo.InvariantCulture, " {0} ({1:P1} - {2:dd\\.hh\\:mm})", (object)(s.Index + 1), (object)s.Percentage, (object)s.PlayTime));
         }
         menuItem.Disabled   = !condition(saveSlotInfo);
         menuItem.Selectable = condition(saveSlotInfo);
     }
     for (int index = 0; index < this.Items.Count; ++index)
     {
         if (level.Items[index].Selectable)
         {
             level.SelectedIndex = index;
             break;
         }
     }
 }
Example #2
0
 private void ReloadSlots()
 {
     for (int index = 0; index < 3; ++index)
     {
         SaveSlotInfo saveSlotInfo = this.Slots[index] = new SaveSlotInfo()
         {
             Index = index
         };
         PCSaveDevice pcSaveDevice = new PCSaveDevice("FEZ");
         string       fileName     = "SaveSlot" + (object)index;
         if (!pcSaveDevice.FileExists(fileName))
         {
             saveSlotInfo.Empty = true;
         }
         else
         {
             SaveData saveData = (SaveData)null;
             if (!pcSaveDevice.Load(fileName, (LoadAction)(stream => saveData = SaveFileOperations.Read(new CrcReader(stream)))) || saveData == null)
             {
                 saveSlotInfo.Empty = true;
             }
             else
             {
                 saveSlotInfo.Percentage = (float)(((double)(saveData.CubeShards + saveData.SecretCubes + saveData.PiecesOfHeart) + (double)saveData.CollectedParts / 8.0) / 32.0);
                 saveSlotInfo.PlayTime   = new TimeSpan(saveData.PlayTime);
                 saveSlotInfo.SaveData   = saveData;
             }
         }
     }
 }
 private void ChooseSaveSlot(SaveSlotInfo slot)
 {
     this.GameState.SaveSlot = slot.Index;
     this.GameState.LoadSaveFile((Action)(() =>
     {
         this.GameState.Save();
         this.GameState.DoSave();
         if (this.RecoverMainMenu == null || !this.RecoverMainMenu())
         {
             return;
         }
         this.RecoverMainMenu = (Func <bool>)null;
     }));
 }
Example #4
0
        private void ChooseSaveSlot(SaveSlotInfo slot, SaveManagementLevel.SMOperation operation)
        {
            switch (operation)
            {
            case SaveManagementLevel.SMOperation.Change:
                this.GameState.SaveSlot = slot.Index;
                this.GameState.LoadSaveFile((Action)(() =>
                {
                    this.GameState.Save();
                    this.GameState.DoSave();
                    this.GameState.SaveToCloud(true);
                    this.GameState.Restart();
                }));
                break;

            case SaveManagementLevel.SMOperation.CopySource:
                this.CopySourceSlot = slot;
                this.RefreshSlotsFor(this.CopyDestLevel, SaveManagementLevel.SMOperation.CopyDestination, (Func <SaveSlotInfo, bool>)(s => this.CopySourceSlot != s));
                this.Menu.ChangeMenuLevel(this.CopyDestLevel, false);
                break;

            case SaveManagementLevel.SMOperation.CopyDestination:
                new PCSaveDevice("FEZ").Save("SaveSlot" + (object)slot.Index, (SaveAction)(writer => SaveFileOperations.Write(new CrcWriter(writer), this.CopySourceSlot.SaveData)));
                this.GameState.SaveToCloud(true);
                this.ReloadSlots();
                this.Menu.ChangeMenuLevel((MenuLevel)this, false);
                break;

            case SaveManagementLevel.SMOperation.Clear:
                new PCSaveDevice("FEZ").Delete("SaveSlot" + (object)slot.Index);
                if (this.GameState.SaveSlot == slot.Index)
                {
                    this.GameState.LoadSaveFile((Action)(() =>
                    {
                        this.GameState.Save();
                        this.GameState.DoSave();
                        this.GameState.SaveToCloud(true);
                        this.GameState.Restart();
                    }));
                    break;
                }
                else
                {
                    this.ReloadSlots();
                    this.Menu.ChangeMenuLevel((MenuLevel)this, false);
                    break;
                }
            }
        }
Example #5
0
 private void ChooseSaveSlot(SaveSlotInfo slot)
 {
   this.GameState.SaveSlot = slot.Index;
   this.GameState.LoadSaveFile((Action) (() =>
   {
     this.GameState.Save();
     this.GameState.DoSave();
     if (this.RecoverMainMenu == null || !this.RecoverMainMenu())
       return;
     this.RecoverMainMenu = (Func<bool>) null;
   }));
 }
Example #6
0
 private void ChooseSaveSlot(SaveSlotInfo slot, SaveManagementLevel.SMOperation operation)
 {
   switch (operation)
   {
     case SaveManagementLevel.SMOperation.Change:
       this.GameState.SaveSlot = slot.Index;
       this.GameState.LoadSaveFile((Action) (() =>
       {
         this.GameState.Save();
         this.GameState.DoSave();
         this.GameState.SaveToCloud(true);
         this.GameState.Restart();
       }));
       break;
     case SaveManagementLevel.SMOperation.CopySource:
       this.CopySourceSlot = slot;
       this.RefreshSlotsFor(this.CopyDestLevel, SaveManagementLevel.SMOperation.CopyDestination, (Func<SaveSlotInfo, bool>) (s => this.CopySourceSlot != s));
       this.Menu.ChangeMenuLevel(this.CopyDestLevel, false);
       break;
     case SaveManagementLevel.SMOperation.CopyDestination:
       new PCSaveDevice("FEZ").Save("SaveSlot" + (object) slot.Index, (SaveAction) (writer => SaveFileOperations.Write(new CrcWriter(writer), this.CopySourceSlot.SaveData)));
       this.GameState.SaveToCloud(true);
       this.ReloadSlots();
       this.Menu.ChangeMenuLevel((MenuLevel) this, false);
       break;
     case SaveManagementLevel.SMOperation.Clear:
       new PCSaveDevice("FEZ").Delete("SaveSlot" + (object) slot.Index);
       if (this.GameState.SaveSlot == slot.Index)
       {
         this.GameState.LoadSaveFile((Action) (() =>
         {
           this.GameState.Save();
           this.GameState.DoSave();
           this.GameState.SaveToCloud(true);
           this.GameState.Restart();
         }));
         break;
       }
       else
       {
         this.ReloadSlots();
         this.Menu.ChangeMenuLevel((MenuLevel) this, false);
         break;
       }
   }
 }
 public extern void ChooseSaveSlot(SaveSlotInfo slot, SMOperation operation);