Exemplo n.º 1
0
        private void PriceChanged(int index, int newPrice, bool pm = false)
        {
            if (_saveData == null)
            {
                return;
            }

            Prices[index] = newPrice;

            // Save price
            switch (_saveData.SaveGeneration)
            {
            case SaveGeneration.N64:
            case SaveGeneration.GCN:
            case SaveGeneration.iQue:
                _saveData.Write(_offset + index * 2, (ushort)newPrice, _saveData.IsBigEndian);
                break;

            case SaveGeneration.N3DS:
                var writeOffset    = _offset + index * 0x10 + (pm ? 8 : 0);
                var encryptedValue = new NewLeafInt32((uint)newPrice);
                _saveData.Write(writeOffset, encryptedValue.Int1);
                _saveData.Write(writeOffset + 4, encryptedValue.Int2);
                break;
            }
        }
Exemplo n.º 2
0
        public BadgeControl(Save save, int index, int offset, int valueOffset)
        {
            if (index >= BadgeNames.Length)
            {
                throw new Exception($"Badge index was invalid! Got {index} when {BadgeNames.Length - 1} was the maximum possible!");
            }

            _saveFile    = save;
            _index       = index;
            _dataOffset  = offset;
            _valueOffset = valueOffset;
            Stage        = _saveFile.ReadByte(offset);
            Value        = new NewLeafInt32(_saveFile.ReadUInt32(valueOffset), _saveFile.ReadUInt32(valueOffset + 4));
            _badgeName   = BadgeNames[index];

            _badgeNameToolTip = new ToolTip
            {
                AutoPopDelay = 5000,
                InitialDelay = 100,
                ReshowDelay  = 500,
                ShowAlways   = true
            };

            _badgeNameToolTip.SetToolTip(PictureBox, _badgeName + $" - [{BadgeLevels[Stage]}] - " + Value.Value);

            Size             = new Size(28, 28);
            ImageMaskingType = MaskingType.None;
            SetImageCrop();
            PictureBox.MouseClick += OnClick;

            Loaded = true;
        }
Exemplo n.º 3
0
 public static void Scan_For_NL_Int32()
 {
     if (MainForm.SaveFile == null || MainForm.SaveFile.SaveGeneration != SaveGeneration.N3DS)
     {
         return;
     }
     using (var int32Stream = File.CreateText(MainForm.AssemblyLocation + "\\" +
                                              (MainForm.SaveFile.SaveType == SaveType.WelcomeAmiibo ? "WA_" : "") + "NL_Int32_Database.txt"))
         for (var i = 0; i < MainForm.SaveFile.WorkingSaveData.Length - 4; i += 4)
         {
             var possibleNlInt32 = new NewLeafInt32(MainForm.SaveFile.ReadUInt32(i), MainForm.SaveFile.ReadUInt32(i + 4));
             if (possibleNlInt32.Valid)
             {
                 int32Stream.WriteLine(
                     $"Found Valid NewLeafInt32 at offset 0x{i:X} | Value: {possibleNlInt32.Value}");
             }
         }
 }
Exemplo n.º 4
0
        private void OnClick(object sender, EventArgs e)
        {
            if (Loaded && _dataOffset > -1 && _valueOffset > -1 && _index > -1 && _index < BadgeNames.Length)
            {
                Stage++;
                if (Stage > 3)
                {
                    Stage = 0;
                }

                Value = new NewLeafInt32((uint)BadgeValues[_index][Stage]);

                if (_saveFile != null)
                {
                    _saveFile.Write(_dataOffset, Stage);
                    _saveFile.Write(_valueOffset, Value.Int1);
                    _saveFile.Write(_valueOffset + 4, Value.Int2);
                }

                SetImageCrop();
                _badgeNameToolTip.SetToolTip(PictureBox, _badgeName + $" - [{BadgeLevels[Stage]}] - " + Value.Value);
            }
        }
Exemplo n.º 5
0
        public StalkMarketEditor(Save saveData)
        {
            AutoSize      = true;
            FlowDirection = FlowDirection.TopDown;

            _saveData   = saveData;
            Prices      = new int[Days];
            _priceBoxes = new NumericTextBox[Days];
            _panels     = new List <FlowLayoutPanel>();

            _offset = _trendOffset = -1;
            switch (_saveData.SaveType)
            {
            case SaveType.AnimalCrossing:
                _offset      = saveData.SaveDataStartOffset + 0x20480;
                _trendOffset = _offset + 0xE;
                break;

            case SaveType.DoubutsuNoMoriEPlus:
            case SaveType.AnimalForestEPlus:
                _offset      = saveData.SaveDataStartOffset + 0x223C8;
                _trendOffset = _offset + 0xE;
                break;

            case SaveType.CityFolk:
                _offset      = saveData.SaveDataStartOffset + 0x63200;
                _trendOffset = _offset + 0x3C;
                break;

            case SaveType.NewLeaf:
                Days    = 6;
                _offset = saveData.SaveDataStartOffset + 0x6535C;
                break;

            case SaveType.WelcomeAmiibo:
                Days    = 6;
                _offset = saveData.SaveDataStartOffset + 0x6AD60;
                break;
            }

            if (_offset < 0)
            {
                Dispose();
                return;
            }

            // Header Label
            Controls.Add(new Label
            {
                AutoSize = true,
                Text     = "Stalk Market"
            });

            // Trend
            if (_trendOffset > -1)
            {
                var trendPanel = new FlowLayoutPanel
                {
                    AutoSize      = true,
                    FlowDirection = FlowDirection.LeftToRight
                };

                var trendLabel = new Label
                {
                    AutoSize  = false,
                    Size      = new Size(130, 22),
                    TextAlign = ContentAlignment.MiddleRight,
                    Text      = "Trend:"
                };
                trendPanel.Controls.Add(trendLabel);

                _trendComboBox = new ComboBox
                {
                    AutoSize = false,
                    Size     = new Size(60, 20)
                };

                switch (saveData.SaveGeneration)
                {
                case SaveGeneration.N64:
                case SaveGeneration.GCN:
                case SaveGeneration.iQue:
                    Trend = saveData.ReadUInt16(_trendOffset, saveData.IsBigEndian);

                    foreach (var trend in Enum.GetNames(typeof(GameCubeStalkMarketTrend)))
                    {
                        _trendComboBox.Items.Add(trend);
                    }

                    break;

                case SaveGeneration.Wii:
                    Trend = (int)saveData.ReadUInt32(_trendOffset, saveData.IsBigEndian);

                    foreach (var trend in Enum.GetNames(typeof(CityFolkStalkMarketTrend)))
                    {
                        _trendComboBox.Items.Add(trend);
                    }

                    break;
                }

                _trendComboBox.SelectedIndex         = Trend;
                _trendComboBox.SelectedIndexChanged += (s, e) => TrendChanged(_trendComboBox.SelectedIndex);
                trendPanel.Controls.Add(_trendComboBox);

                _panels.Add(trendPanel);
                Controls.Add(trendPanel);
            }

            // Prices
            var offset = _offset;

            // City Folk has a Sunday buy price that differs from the Sunday AM/PM prices.
            if (saveData.SaveGeneration == SaveGeneration.Wii)
            {
                // TODO: Do we want to offer a way to change the buy price?
                var buyPriceFromJoan = saveData.ReadUInt32(offset, true);
                offset += 4;
            }

            for (var day = 0; day < Days; day++)
            {
                switch (_saveData.SaveGeneration)
                {
                case SaveGeneration.N64:
                case SaveGeneration.GCN:
                case SaveGeneration.iQue:
                {
                    Prices[day] = saveData.ReadUInt16(offset, saveData.IsBigEndian);
                    offset     += 2;

                    var pricePanel = new FlowLayoutPanel
                    {
                        AutoSize      = true,
                        FlowDirection = FlowDirection.LeftToRight
                    };

                    var priceLabel = new Label
                    {
                        AutoSize  = false,
                        Size      = new Size(130, 22),
                        TextAlign = ContentAlignment.MiddleRight,
                        Text      = $"{DayNames[day]}'s Price:"
                    };
                    pricePanel.Controls.Add(priceLabel);

                    _priceBoxes[day] = new NumericTextBox
                    {
                        AutoSize  = false,
                        Size      = new Size(60, 20),
                        Location  = new Point(5, day * 24),
                        Text      = Prices[day].ToString(),
                        MaxLength = 4
                    };

                    var currentDay = day;
                    _priceBoxes[day].TextChanged += (s, e) =>
                                                    PriceChanged(currentDay, int.Parse(_priceBoxes[currentDay].Text));
                    pricePanel.Controls.Add(_priceBoxes[day]);
                    _panels.Add(pricePanel);
                    Controls.Add(pricePanel);
                    break;
                }

                case SaveGeneration.Wii:
                {
                    var amPrice = saveData.ReadUInt32(offset, true);
                    var pmPrice = saveData.ReadUInt32(offset + 4, true);
                    offset += 8;

                    for (var i = 0; i < 2; i++)
                    {
                        var pricePanel = new FlowLayoutPanel
                        {
                            AutoSize      = true,
                            FlowDirection = FlowDirection.LeftToRight
                        };

                        var priceLabel = new Label
                        {
                            AutoSize  = false,
                            Size      = new Size(130, 22),
                            TextAlign = ContentAlignment.MiddleRight,
                            Text      = $"{DayNames[day]}'s Price [{(i == 0 ? "AM" : "PM")}]:"
                        };
                        pricePanel.Controls.Add(priceLabel);

                        var priceBox = new NumericTextBox
                        {
                            AutoSize  = false,
                            Size      = new Size(60, 20),
                            Location  = new Point(5, day * 24),
                            Text      = (i == 0 ? amPrice : pmPrice).ToString(),
                            MaxLength = 9
                        };

                        var currentDay = day;
                        priceBox.TextChanged += (s, e) =>
                                                PriceChanged(currentDay, int.Parse(priceBox.Text));
                        pricePanel.Controls.Add(priceBox);
                        _panels.Add(pricePanel);
                        Controls.Add(pricePanel);
                    }

                    break;
                }

                case SaveGeneration.N3DS:
                {
                    var amPrice = new NewLeafInt32(saveData.ReadUInt32(offset), saveData.ReadUInt32(offset + 4)).Value;
                    var pmPrice = new NewLeafInt32(saveData.ReadUInt32(offset + 8), saveData.ReadUInt32(offset + 0xC)).Value;
                    offset += 0x10;

                    for (var i = 0; i < 2; i++)
                    {
                        var pricePanel = new FlowLayoutPanel
                        {
                            AutoSize      = true,
                            FlowDirection = FlowDirection.LeftToRight
                        };

                        var priceLabel = new Label
                        {
                            AutoSize  = false,
                            Size      = new Size(130, 22),
                            TextAlign = ContentAlignment.MiddleRight,
                            Text      = $"{DayNames[day + 1]}'s Price [{(i == 0 ? "AM" : "PM")}]:"
                        };
                        pricePanel.Controls.Add(priceLabel);

                        var priceBox = new NumericTextBox
                        {
                            AutoSize  = false,
                            Size      = new Size(60, 20),
                            Location  = new Point(5, day * 24),
                            Text      = (i == 0 ? amPrice : pmPrice).ToString(),
                            MaxLength = 9
                        };

                        var currentDay = day;
                        priceBox.TextChanged += (s, e) =>
                                                PriceChanged(currentDay, int.Parse(priceBox.Text));
                        pricePanel.Controls.Add(priceBox);
                        _panels.Add(pricePanel);
                        Controls.Add(pricePanel);
                    }

                    break;
                }
                }
            }
        }