Example #1
0
 bool MAINBUFFERtoFormData()
 {
     //load values into form
     try
     {
         //+->general
         SObject root = MAINBUFFER.GetObject();
         InputPlaytime.Value           = root.Get("play-time").GetInteger();
         InputSpawnX.Value             = (decimal)root.Get("spawn-pos").GetObject().Get("x").GetFloat();
         InputSpawnY.Value             = (decimal)root.Get("spawn-pos").GetObject().Get("y").GetFloat();
         InputLevelID.Text             = root.Get("level-id").GetString();
         InputDifficulty.SelectedIndex = root.Get("difficulty").GetInteger();
         checkboxNetworked.Checked     = root.Get("networked").GetBoolean();
         //+->modifiers
         SObject modifiers = root.Get("modifiers").GetObject();
         //  +->challenges
         checkBoxNoExtraLives.Checked   = modifiers.Get("nolives").GetBoolean();
         checkBox1HP.Checked            = modifiers.Get("1hp").GetBoolean();
         checkBoxSharedHPPool.Checked   = modifiers.Get("sharehp").GetBoolean();
         checkBoxNoHPPickups.Checked    = modifiers.Get("nohppup").GetBoolean();
         checkBoxNoManaRegen.Checked    = modifiers.Get("nomanaregen").GetBoolean();
         checkBoxReverseHPRegen.Checked = modifiers.Get("revhpregen").GetBoolean();
         //  +->crutches
         checkBoxInfiniteLives.Checked = modifiers.Get("inflives").GetBoolean();
         checkBoxHPRegen.Checked       = modifiers.Get("hpregen").GetBoolean();
         checkBoxDoubleDamage.Checked  = modifiers.Get("doubledmg").GetBoolean();
         checkBoxDoubleLives.Checked   = modifiers.Get("doublelife").GetBoolean();
         checkBox5XManaRegen.Checked   = modifiers.Get("quickmana").GetBoolean();
         //+->players
         players = new List <SValue>();
         foreach (SValue player in root.Get("players").GetArray())
         {
             if (!player.IsNull())
             {
                 players.Add(player.GetObject());
                 playerListView.Items.Add(player.GetObject().Get("name").GetString(), player.GetObject().Get("class").GetInteger());
             }
         }
         return(true);
     }
     catch (Exception e)
     {
         ResetForm();
         MessageBox.Show("Invalid save data. The data is either corrupted or did not adhere to a recognized format.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         toolStripStatusLabel.Text        = "Error encountered while loading.";
         toolStripStatusLabel.ToolTipText = "Invalid save data. The file is either corrupted or not a valid save.";
         return(false);
     }
 }