Ejemplo n.º 1
0
        private void ExecuteOpenSavegame(object parameter)
        {
            if (parameter == null)
            {
                return;
            }

            var savegame = parameter as SavegameModel;

            if (savegame == null)
            {
                throw new ArgumentException("parameter");
            }

            SavegameFile.ReadAsync(savegame.Path, Progress)
            .ContinueWith(t =>
            {
                var file = t.Result;
                var savegameDataModel = new SavegameDataModel
                {
                    Version1      = file.TypeCode1,
                    Version2      = file.TypeCode2,
                    Version3      = file.TypeCode3,
                    VariableNames = new ObservableCollection <string>(file.VariableNames),
                    Variables     = new ObservableCollection <VariableModel>(file.Variables.Select(ToVariableModel))
                };
                SelectedSavegame = new SavegameModel
                {
                    Name = savegame.Name,
                    Path = savegame.Path,
                    Data = savegameDataModel
                };
            });
        }
Ejemplo n.º 2
0
 private void savesTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
 {
     try
     {
         var save       = Savegames.FirstOrDefault(x => x.Name == e.Node.Text);
         var parsedsave = SavegameFile.Read(save.Path);
         saveNameBox.Text         = save.Name;
         saveIcon.BackgroundImage = new Bitmap(save.ThumbnailPath);
         saveVersionBox.Text      = parsedsave.TypeCode1 + "." + parsedsave.TypeCode2 + "." + parsedsave.TypeCode3;
         saveNamesBox.Text        = parsedsave.VariableNames.Count().ToString();
         saveVariableBox.Text     = parsedsave.Variables.Count().ToString();
         variablesList.Items.Clear();
         foreach (var node in parsedsave.Variables.Select(ToVariableModel).ToList())
         {
             var variablenode = new ListViewItem();
             variablenode.Text = node.Index.ToString();
             variablenode.SubItems.Add(node.Name);
             variablenode.SubItems.Add(node.Type);
             variablenode.SubItems.Add(node.Value == "" ? "NONE" : node.Value);
             variablenode.SubItems.Add(node.DebugString);
             variablenode.SubItems.Add(node.Children.Count().ToString());
             variablesList.Items.Add(variablenode);
         }
     }
     catch
     {
     }
 }
 private void SetFileProperties(CartridgeTag tag, string saveFilename = null)
 {
     if (saveFilename == null)
     {
         string fname = System.IO.Path.GetFileNameWithoutExtension(tag.Cartridge.Filename);
         SavegameFile = String.Format("{0}/{1}_{2}.gws",
                                      tag.PathToSavegames,
                                      Name.ReplaceInvalidFileNameChars(),
                                      fname.ReplaceInvalidFileNameChars()
                                      );
     }
     else
     {
         SavegameFile = String.Format("{0}/{1}", tag.PathToSavegames, saveFilename);
         if (!SavegameFile.EndsWith(".gws", StringComparison.InvariantCultureIgnoreCase))
         {
             SavegameFile += ".gws";
         }
     }
     MetadataFile = SavegameFile + ".mf";
 }