private void numericUpDownWateredTimes_ValueChanged(object sender, EventArgs e)
 {
     if (listBoxPlants.SelectedIndices.Count == 1)
     {
         ZenGardenPlant plant = user.ZenGardenPlants[listBoxPlants.SelectedIndex];
         plant.NumTimesWatered = (int)numericUpDownWateredTimes.Value;
         MarkChanged(true);
     }
 }
 private void numericUpDownColumn_ValueChanged(object sender, EventArgs e)
 {
     if (listBoxPlants.SelectedIndices.Count == 1)
     {
         ZenGardenPlant plant = user.ZenGardenPlants[listBoxPlants.SelectedIndex];
         plant.Column = (int)numericUpDownColumn.Value - 1;
         MarkChanged(true);
         PopulatePlantList();
     }
 }
 private void UpdateFertilized()
 {
     if (listBoxPlants.SelectedIndices.Count == 1)
     {
         ZenGardenPlant plant = user.ZenGardenPlants[listBoxPlants.SelectedIndex];
         plant.LastFertilizerTime = checkBoxNeverFertilized.Checked ? DateTime.MinValue : dateTimePickerLastFertilized.Value;
         MarkChanged(true);
         UpdatePlantDetails();
     }
 }
 private void UpdateHappiness()
 {
     if (listBoxPlants.SelectedIndices.Count == 1)
     {
         ZenGardenPlant plant = user.ZenGardenPlants[listBoxPlants.SelectedIndex];
         plant.LastPhonographOrBugSprayTime = checkBoxNeverHappiness.Checked ? DateTime.MinValue : dateTimePickerLastHappiness.Value;
         MarkChanged(true);
         UpdatePlantDetails();
     }
 }
 private void comboBoxPlantType_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listBoxPlants.SelectedIndices.Count == 1)
     {
         ZenGardenPlant plant = user.ZenGardenPlants[listBoxPlants.SelectedIndex];
         plant.PlantType = comboBoxPlantType.SelectedIndex;
         MarkChanged(true);
         PopulatePlantList();
     }
 }
 private void comboBoxColor_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listBoxPlants.SelectedIndices.Count == 1)
     {
         ZenGardenPlant plant = user.ZenGardenPlants[listBoxPlants.SelectedIndex];
         if (plant.PlantType == ZenGardenPlant.Marigold)
         {
             plant.Color = comboBoxColor.SelectedIndex + 1;
         }
         MarkChanged(true);
         PopulatePlantList();
     }
 }
        private void buttonDuplicate_Click(object sender, EventArgs e)
        {
            var list    = new List <ZenGardenPlant>(user.ZenGardenPlants);
            var indices = new List <int>();

            foreach (int index in listBoxPlants.SelectedIndices)
            {
                ZenGardenPlant plant = new ZenGardenPlant(list[index]);
                list.Add(plant);
            }
            user.ZenGardenPlants = list.ToArray();
            MarkChanged(true);
            PopulatePlantList();
        }
 private void comboBoxGarden_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listBoxPlants.SelectedIndices.Count == 1)
     {
         ZenGardenPlant plant = user.ZenGardenPlants[listBoxPlants.SelectedIndex];
         plant.GardenLocation = comboBoxGarden.SelectedIndex;
         if (plant.GardenLocation != 0)
         {
             plant.Row = 0;
         }
         MarkChanged(true);
         UpdatePlantDetails();
         PopulatePlantList();
     }
 }
        private void comboBoxHappiness_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listBoxPlants.SelectedIndices.Count == 1)
            {
                ZenGardenPlant plant = user.ZenGardenPlants[listBoxPlants.SelectedIndex];
                switch (comboBoxHappiness.SelectedIndex)
                {
                case 0: plant.NeedsPhonographOrBugSpray = ZenGardenPlantNeeds.Nothing; break;

                case 1: plant.NeedsPhonographOrBugSpray = ZenGardenPlantNeeds.BugSpray; break;

                case 2: plant.NeedsPhonographOrBugSpray = ZenGardenPlantNeeds.Phonograph; break;
                }
                MarkChanged(true);
            }
        }
 public ZenGardenPlant(ZenGardenPlant plant)
 {
     PlantType      = plant.PlantType;
     GardenLocation = plant.GardenLocation;
     Column         = plant.Column;
     Row            = plant.Row;
     Array.Copy(plant.unknown1, unknown1, 2);
     LastWateringTime             = plant.LastWateringTime;
     unknown2                     = plant.unknown2;
     Color                        = plant.Color;
     NumTimesFertilized           = plant.NumTimesFertilized;
     NumTimesWatered              = plant.NumTimesWatered;
     unknown3                     = plant.unknown3;
     NeedsPhonographOrBugSpray    = plant.NeedsPhonographOrBugSpray;
     unknown4                     = plant.unknown4;
     LastPhonographOrBugSprayTime = plant.LastPhonographOrBugSprayTime;
     unknown5                     = plant.unknown5;
     LastFertilizerTime           = plant.LastFertilizerTime;
     Array.Copy(plant.unknown6, unknown6, 5);
 }
        private void buttonLoadPlant_Click(object sender, EventArgs e)
        {
            var dialog = new OpenFileDialog();

            if (dialog.ShowDialog(this) == DialogResult.OK)
            {
                using (var reader = new BinaryReader(new FileStream(dialog.FileName, FileMode.Open, FileAccess.Read)))
                {
                    var version = reader.ReadUInt32();
                    if (version != 0x0C)
                    {
                        IncompatibleVersion();
                    }
                    ZenGardenPlant plant = new ZenGardenPlant();
                    plant.Load(reader);

                    var list = new List <ZenGardenPlant>(user.ZenGardenPlants);
                    list.Add(plant);
                    user.ZenGardenPlants = list.ToArray();
                    MarkChanged(true);
                    PopulatePlantList();
                }
            }
        }
        private void buttonLoadPlant_Click(object sender, EventArgs e)
        {
            var dialog = new OpenFileDialog();
            if (dialog.ShowDialog(this) == DialogResult.OK)
            {
                using (var reader = new BinaryReader(new FileStream(dialog.FileName, FileMode.Open, FileAccess.Read)))
                {
                    var version = reader.ReadUInt32();
                    if (version != 0x0C)
                    {
                        IncompatibleVersion();
                    }
                    ZenGardenPlant plant = new ZenGardenPlant();
                    plant.Load(reader);

                    var list = new List<ZenGardenPlant>(user.ZenGardenPlants);
                    list.Add(plant);
                    user.ZenGardenPlants = list.ToArray();
                    MarkChanged(true);
                    PopulatePlantList();
                }
            }
        }
        private void UpdatePlantDetails()
        {
            comboBoxPlantType.Enabled    = comboBoxColor.Enabled = comboBoxGarden.Enabled = comboBoxHappiness.Enabled =
                numericUpDownRow.Enabled = numericUpDownColumn.Enabled =
                    numericUpDownWateredTimes.Enabled     = numericUpDownFertilizedTimes.Enabled =
                        dateTimePickerLastWatered.Enabled = dateTimePickerLastFertilized.Enabled = dateTimePickerLastHappiness.Enabled =
                            checkBoxNeverWatered.Enabled  = checkBoxNeverFertilized.Enabled = checkBoxNeverHappiness.Enabled =
                                (listBoxPlants.SelectedIndices.Count == 1);
            if (listBoxPlants.SelectedIndices.Count == 1 && listBoxPlants.SelectedIndex < user.ZenGardenPlants.Length)
            {
                ZenGardenPlant plant = user.ZenGardenPlants[listBoxPlants.SelectedIndex];
                comboBoxPlantType.SelectedIndex = plant.PlantType;
                if (plant.PlantType == ZenGardenPlant.Marigold)
                {
                    comboBoxColor.Enabled       = true;
                    comboBoxColor.SelectedIndex = plant.Color - 1;
                }
                else
                {
                    comboBoxColor.Enabled       = false;
                    comboBoxColor.SelectedIndex = -1;
                }
                comboBoxGarden.SelectedIndex = plant.GardenLocation;
                if (plant.GardenLocation != 0)
                {
                    numericUpDownRow.Enabled = false;
                }
                else
                {
                    numericUpDownRow.Enabled = true;
                    numericUpDownRow.Value   = plant.Row + 1;
                }
                numericUpDownColumn.Value = plant.Column + 1;

                numericUpDownWateredTimes.Value = plant.NumTimesWatered;
                if (plant.LastWateringTime == DateTime.MinValue)
                {
                    checkBoxNeverWatered.Checked      = true;
                    dateTimePickerLastWatered.Enabled = false;
                }
                else
                {
                    dateTimePickerLastWatered.Enabled = true;
                    dateTimePickerLastWatered.Value   = plant.LastWateringTime;
                }
                numericUpDownFertilizedTimes.Value = plant.NumTimesFertilized;
                if (plant.LastFertilizerTime == DateTime.MinValue)
                {
                    checkBoxNeverFertilized.Checked      = true;
                    dateTimePickerLastFertilized.Enabled = false;
                }
                else
                {
                    dateTimePickerLastFertilized.Enabled = true;
                    dateTimePickerLastFertilized.Value   = plant.LastFertilizerTime;
                }
                switch (plant.NeedsPhonographOrBugSpray)
                {
                case ZenGardenPlantNeeds.Nothing: comboBoxHappiness.SelectedIndex = 0; break;

                case ZenGardenPlantNeeds.BugSpray: comboBoxHappiness.SelectedIndex = 1; break;

                case ZenGardenPlantNeeds.Phonograph: comboBoxHappiness.SelectedIndex = 2; break;
                }
                if (plant.LastPhonographOrBugSprayTime == DateTime.MinValue)
                {
                    checkBoxNeverHappiness.Checked      = true;
                    dateTimePickerLastHappiness.Enabled = false;
                }
                else
                {
                    checkBoxNeverHappiness.Checked      = false;
                    dateTimePickerLastHappiness.Enabled = true;
                    dateTimePickerLastHappiness.Value   = plant.LastPhonographOrBugSprayTime;
                }
            }
        }
 public ZenGardenPlant(ZenGardenPlant plant)
 {
     PlantType = plant.PlantType;
     GardenLocation = plant.GardenLocation;
     Column = plant.Column;
     Row = plant.Row;
     Array.Copy(plant.unknown1, unknown1, 2);
     LastWateringTime = plant.LastWateringTime;
     unknown2 = plant.unknown2;
     Color = plant.Color;
     NumTimesFertilized = plant.NumTimesFertilized;
     NumTimesWatered = plant.NumTimesWatered;
     unknown3 = plant.unknown3;
     NeedsPhonographOrBugSpray = plant.NeedsPhonographOrBugSpray;
     unknown4 = plant.unknown4;
     LastPhonographOrBugSprayTime = plant.LastPhonographOrBugSprayTime;
     unknown5 = plant.unknown5;
     LastFertilizerTime = plant.LastFertilizerTime;
     Array.Copy(plant.unknown6, unknown6, 5);
 }
Example #15
0
        public void Load(bool forceReadIncompatibleVersion)
        {
            using (var reader = new BinaryReader(new FileStream(UserFilePath, FileMode.Open, FileAccess.Read)))
            {
                var version = reader.ReadUInt32();
                if (version != 0x0C && !forceReadIncompatibleVersion)
                {
                    throw new IncompatibleVersionException();
                }
                Level.Read(reader);
                moneyOver10 = reader.ReadInt32();
                NumTimesAdventureModeCompleted = reader.ReadInt32();

                IOUtils.ReadInt32Array(reader, SurvivalModeFlags);
                IOUtils.ReadUInt32Array(reader, unknown1);
                StreakLengthEndlessSurvival = reader.ReadInt32();

                IOUtils.ReadUInt32Array(reader, unknown2);

                IOUtils.ReadBoolPreserveNonzeroArray(reader, HasMinigameTrophy, 4);
                IOUtils.ReadUInt32Array(reader, unknown3);
                TreeOfWisdomHeight = reader.ReadInt32();
                IOUtils.ReadBoolPreserveNonzeroArray(reader, HasVaseBreakerTrophy, 4);
                StreakLengthVaseBreakerEndless = reader.ReadInt32();
                IOUtils.ReadBoolPreserveNonzeroArray(reader, HasIZombieTrophy, 4);
                StreakLengthIZombieEndless = reader.ReadInt32();

                IOUtils.ReadUInt32Array(reader, unknown4);

                IOUtils.ReadBoolPreserveNonzeroArray(reader, HasShopPlant, 4);
                unknown5 = reader.ReadUInt32();
                for (int i = 0; i < MarigoldLastPurchased.Length; i++)
                {
                    MarigoldLastPurchased[i] = IOUtils.ReadDaysSince2000(reader);
                }
                HasGoldenWateringCan  = IOUtils.ReadBoolPreserveNonzero(reader, 4);
                FertilizerAmount      = IOUtils.ReadInt32Offset(reader, 1000);
                BugSprayAmount        = IOUtils.ReadInt32Offset(reader, 1000);
                HasPhonograph         = IOUtils.ReadBoolPreserveNonzero(reader, 4);
                HasGardeningGlove     = IOUtils.ReadBoolPreserveNonzero(reader, 4);
                HasMushroomGarden     = IOUtils.ReadBoolPreserveNonzero(reader, 4);
                HasWheelbarrow        = IOUtils.ReadBoolPreserveNonzero(reader, 4);
                StinkyLastAwokenTime  = IOUtils.ReadUnixTimestamp(reader);
                NumberSlots           = reader.ReadInt32() + 6;
                HasPoolCleaners       = IOUtils.ReadBoolPreserveNonzero(reader, 4);
                HasRoofCleaners       = IOUtils.ReadBoolPreserveNonzero(reader, 4);
                RakeUses              = reader.ReadUInt32();
                HasAquariumGarden     = IOUtils.ReadBoolPreserveNonzero(reader, 4);
                ChocolateAmount       = IOUtils.ReadInt32Offset(reader, 1000);
                TreeOfWisdomAvailable = IOUtils.ReadBoolPreserveNonzero(reader, 4);
                TreeFoodAmount        = IOUtils.ReadInt32Offset(reader, 1000);
                HasWallNutFirstAid    = IOUtils.ReadBoolPreserveNonzero(reader, 4);
                IOUtils.ReadUInt32Array(reader, unknown6);
                unknown7 = reader.ReadUInt32();
                StinkyLastChocolateTime  = IOUtils.ReadUnixTimestamp(reader);
                StinkyXPosition          = reader.ReadInt32();
                StinkyYPosition          = reader.ReadInt32();
                MiniGamesUnlocked        = IOUtils.ReadBoolPreserveNonzero(reader, 4);
                PuzzleModeUnlocked       = IOUtils.ReadBoolPreserveNonzero(reader, 4);
                AnimateUnlockMiniGame    = IOUtils.ReadBoolPreserveNonzero(reader, 4);
                AnimateUnlockVasebreaker = IOUtils.ReadBoolPreserveNonzero(reader, 4);
                AnimateUnlockIZombie     = IOUtils.ReadBoolPreserveNonzero(reader, 4);
                AnimateUnlockSurvival    = IOUtils.ReadBoolPreserveNonzero(reader, 4);
                unknown8 = reader.ReadUInt32();
                ShowAdventureCompleteDialog = IOUtils.ReadBoolPreserveNonzero(reader, 4);
                HasTaco = IOUtils.ReadBoolPreserveNonzero(reader, 4);

                IOUtils.ReadUInt32Array(reader, unknown9);

                var numZenGardenPlants = reader.ReadUInt32();
                ZenGardenPlants = new ZenGardenPlant[numZenGardenPlants];
                for (int i = 0; i < ZenGardenPlants.Length; i++)
                {
                    ZenGardenPlants[i] = new ZenGardenPlant();
                    ZenGardenPlants[i].Load(reader);
                }

                IOUtils.ReadBoolPreserveNonzeroArray(reader, HasAchievement, 2);

                AcceptedZombatarLicenseAgreement = IOUtils.ReadBoolPreserveNonzero(reader, 1);
                var numZombatars = reader.ReadUInt32();
                Zombatars = new Zombatar[numZombatars];
                for (int i = 0; i < Zombatars.Length; i++)
                {
                    Zombatars[i] = new Zombatar();
                    Zombatars[i].Load(reader);
                }

                IOUtils.ReadUInt32Array(reader, unknown10);

                HaveCreatedZombatar = IOUtils.ReadBoolPreserveNonzero(reader, 1);

                // Read all trailing data into a buffer - if we're dealing with an incompatible version this might let us succeed
                // Warning: this might allocate a lot of memory if the file is huge for some reason
                trailingData = reader.ReadBytes((int)new FileInfo(UserFilePath).Length);
            }
        }
        public void Load(bool forceReadIncompatibleVersion)
        {
            using (var reader = new BinaryReader(new FileStream(UserFilePath, FileMode.Open, FileAccess.Read)))
            {
                var version = reader.ReadUInt32();
                if (version != 0x0C && !forceReadIncompatibleVersion)
                {
                    throw new IncompatibleVersionException();
                }
                Level.Read(reader);
                moneyOver10 = reader.ReadInt32();
                NumTimesAdventureModeCompleted = reader.ReadInt32();

                IOUtils.ReadInt32Array(reader, SurvivalModeFlags);
                IOUtils.ReadUInt32Array(reader, unknown1);
                StreakLengthEndlessSurvival = reader.ReadInt32();

                IOUtils.ReadUInt32Array(reader, unknown2);

                IOUtils.ReadBoolPreserveNonzeroArray(reader, HasMinigameTrophy, 4);
                IOUtils.ReadUInt32Array(reader, unknown3);
                TreeOfWisdomHeight = reader.ReadInt32();
                IOUtils.ReadBoolPreserveNonzeroArray(reader, HasVaseBreakerTrophy, 4);
                StreakLengthVaseBreakerEndless = reader.ReadInt32();
                IOUtils.ReadBoolPreserveNonzeroArray(reader, HasIZombieTrophy, 4);
                StreakLengthIZombieEndless = reader.ReadInt32();

                IOUtils.ReadUInt32Array(reader, unknown4);

                IOUtils.ReadBoolPreserveNonzeroArray(reader, HasShopPlant, 4);
                unknown5 = reader.ReadUInt32();
                for (int i=0; i < MarigoldLastPurchased.Length; i++)
                {
                    MarigoldLastPurchased[i] = IOUtils.ReadDaysSince2000(reader);
                }
                HasGoldenWateringCan = IOUtils.ReadBoolPreserveNonzero(reader, 4);
                FertilizerAmount = IOUtils.ReadInt32Offset(reader, 1000);
                BugSprayAmount = IOUtils.ReadInt32Offset(reader, 1000);
                HasPhonograph = IOUtils.ReadBoolPreserveNonzero(reader, 4);
                HasGardeningGlove = IOUtils.ReadBoolPreserveNonzero(reader, 4);
                HasMushroomGarden = IOUtils.ReadBoolPreserveNonzero(reader, 4);
                HasWheelbarrow = IOUtils.ReadBoolPreserveNonzero(reader, 4);
                StinkyLastAwokenTime = IOUtils.ReadUnixTimestamp(reader);
                NumberSlots = reader.ReadInt32() + 6;
                HasPoolCleaners = IOUtils.ReadBoolPreserveNonzero(reader, 4);
                HasRoofCleaners = IOUtils.ReadBoolPreserveNonzero(reader, 4);
                RakeUses = reader.ReadUInt32();
                HasAquariumGarden = IOUtils.ReadBoolPreserveNonzero(reader, 4);
                ChocolateAmount = IOUtils.ReadInt32Offset(reader, 1000);
                TreeOfWisdomAvailable = IOUtils.ReadBoolPreserveNonzero(reader, 4);
                TreeFoodAmount = IOUtils.ReadInt32Offset(reader, 1000);
                HasWallNutFirstAid = IOUtils.ReadBoolPreserveNonzero(reader, 4);
                IOUtils.ReadUInt32Array(reader, unknown6);
                unknown7 = reader.ReadUInt32();
                StinkyLastChocolateTime = IOUtils.ReadUnixTimestamp(reader);
                StinkyXPosition = reader.ReadInt32();
                StinkyYPosition = reader.ReadInt32();
                MiniGamesUnlocked = IOUtils.ReadBoolPreserveNonzero(reader, 4);
                PuzzleModeUnlocked = IOUtils.ReadBoolPreserveNonzero(reader, 4);
                AnimateUnlockMiniGame = IOUtils.ReadBoolPreserveNonzero(reader, 4);
                AnimateUnlockVasebreaker = IOUtils.ReadBoolPreserveNonzero(reader, 4);
                AnimateUnlockIZombie = IOUtils.ReadBoolPreserveNonzero(reader, 4);
                AnimateUnlockSurvival = IOUtils.ReadBoolPreserveNonzero(reader, 4);
                unknown8 = reader.ReadUInt32();
                ShowAdventureCompleteDialog = IOUtils.ReadBoolPreserveNonzero(reader, 4);
                HasTaco = IOUtils.ReadBoolPreserveNonzero(reader, 4);

                IOUtils.ReadUInt32Array(reader, unknown9);

                var numZenGardenPlants = reader.ReadUInt32();
                ZenGardenPlants = new ZenGardenPlant[numZenGardenPlants];
                for (int i = 0; i < ZenGardenPlants.Length; i++)
                {
                    ZenGardenPlants[i] = new ZenGardenPlant();
                    ZenGardenPlants[i].Load(reader);
                }

                IOUtils.ReadBoolPreserveNonzeroArray(reader, HasAchievement, 2);

                AcceptedZombatarLicenseAgreement = IOUtils.ReadBoolPreserveNonzero(reader, 1);
                var numZombatars = reader.ReadUInt32();
                Zombatars = new Zombatar[numZombatars];
                for (int i = 0; i < Zombatars.Length; i++)
                {
                    Zombatars[i] = new Zombatar();
                    Zombatars[i].Load(reader);
                }

                IOUtils.ReadUInt32Array(reader, unknown10);

                HaveCreatedZombatar = IOUtils.ReadBoolPreserveNonzero(reader, 1);

                // Read all trailing data into a buffer - if we're dealing with an incompatible version this might let us succeed
                // Warning: this might allocate a lot of memory if the file is huge for some reason
                trailingData = reader.ReadBytes((int)new FileInfo(UserFilePath).Length);
            }
        }
 private void buttonDuplicate_Click(object sender, EventArgs e)
 {
     var list = new List<ZenGardenPlant>(user.ZenGardenPlants);
     var indices = new List<int>();
     foreach (int index in listBoxPlants.SelectedIndices)
     {
         ZenGardenPlant plant = new ZenGardenPlant(list[index]);
         list.Add(plant);
     }
     user.ZenGardenPlants = list.ToArray();
     MarkChanged(true);
     PopulatePlantList();
 }