Exemple #1
0
 private void SaveCFGButton_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {
     foreach (System.Windows.Controls.ListViewItem listViewItem in (IEnumerable)this.mLoadedCFGsListView.Items)
     {
         if (listViewItem.Content.ToString().EndsWith("* (modified)", StringComparison.InvariantCulture))
         {
             try
             {
                 string   fullFilePath = listViewItem.Tag.ToString();
                 IMConfig index        = this.mLoadedCFGDict[fullFilePath];
                 List <IMControlScheme> imControlSchemeList = new List <IMControlScheme>();
                 foreach (IMControlScheme controlScheme in index.ControlSchemes)
                 {
                     IMControlScheme imControlScheme = controlScheme.DeepCopy();
                     imControlScheme.SetGameControls(this.GetFinalListOfActions(this.mSchemeTreeMapping[index][controlScheme]));
                     imControlSchemeList.Add(imControlScheme);
                 }
                 index.ControlSchemes = imControlSchemeList;
                 JsonSerializerSettings serializerSettings = Utils.GetSerializerSettings();
                 serializerSettings.Formatting = Formatting.Indented;
                 this.WriteFile(fullFilePath, JsonConvert.SerializeObject((object)index, serializerSettings));
                 listViewItem.Content = (object)listViewItem.Content.ToString().TrimEnd("* (modified)".ToCharArray());
             }
             catch (Exception ex)
             {
                 string str = string.Format("Couldn't write to file: {0}, Ex: {1}", (object)listViewItem.Tag.ToString(), (object)ex);
                 Logger.Error(str);
                 int num = (int)System.Windows.MessageBox.Show(str);
             }
         }
     }
 }
Exemple #2
0
    public IMControlScheme DeepCopy()
    {
        IMControlScheme imControlScheme = (IMControlScheme)this.MemberwiseClone();
        List <IMAction> gameControls    = this.GameControls;

        imControlScheme.SetGameControls(gameControls != null ? gameControls.DeepCopy <List <IMAction> >() : (List <IMAction>)null);
        imControlScheme.SetImages(this.Images.ConvertAll <JObject>((Converter <JObject, JObject>)(jt => (JObject)jt?.DeepClone())));
        return(imControlScheme);
    }