예제 #1
0
파일: BadgeControl.cs 프로젝트: Slattz/ACSE
        public BadgeControl(Save save, int index, int offset, int valueOffset) : base()
        {
            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 NL_Int32(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;
        }
예제 #2
0
 public static void Scan_For_NL_Int32()
 {
     if (NewMainForm.Save_File != null && (NewMainForm.Save_File.Save_Type == SaveType.New_Leaf || NewMainForm.Save_File.Save_Type == SaveType.Welcome_Amiibo))
     {
         for (int i = 0; i < NewMainForm.Save_File.Working_Save_Data.Length; i += 4)
         {
             NL_Int32 Possible_NL_Int32 = new NL_Int32(NewMainForm.Save_File.ReadUInt32(i), NewMainForm.Save_File.ReadUInt32(i + 4));
             if (Possible_NL_Int32.Valid)
             {
                 System.Windows.Forms.MessageBox.Show(string.Format("Found Valid NL_Int32 at offset 0x{0} | Value: {1}", i.ToString("X"), Possible_NL_Int32.Value));
             }
         }
     }
 }
예제 #3
0
 public static void Scan_For_NL_Int32()
 {
     if (NewMainForm.Save_File != null && (NewMainForm.Save_File.Save_Type == SaveType.New_Leaf || NewMainForm.Save_File.Save_Type == SaveType.Welcome_Amiibo))
     {
         using (StreamWriter Int32_Stream = File.CreateText(NewMainForm.Assembly_Location + "\\" +
                                                            (NewMainForm.Save_File.Save_Type == SaveType.Welcome_Amiibo ? "WA_" : "") + "NL_Int32_Database.txt"))
             for (int i = 0; i < NewMainForm.Save_File.Working_Save_Data.Length - 4; i += 4)
             {
                 NL_Int32 Possible_NL_Int32 = new NL_Int32(NewMainForm.Save_File.ReadUInt32(i), NewMainForm.Save_File.ReadUInt32(i + 4));
                 if (Possible_NL_Int32.Valid)
                 {
                     Int32_Stream.WriteLine(string.Format("Found Valid NL_Int32 at offset 0x{0} | Value: {1}", i.ToString("X"), Possible_NL_Int32.Value));
                 }
             }
     }
 }
예제 #4
0
파일: BadgeControl.cs 프로젝트: Slattz/ACSE
        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 NL_Int32((uint)BadgeValues[Index][Stage]);

                if (SaveFile != null)
                {
                    SaveFile.Write(DataOffset, Stage);
                    SaveFile.Write(ValueOffset, Value.Int_1);
                    SaveFile.Write(ValueOffset + 4, Value.Int_2);
                }

                SetImageCrop();
                BadgeNameToolTip.SetToolTip(pictureBox, BadgeName + $" - [{BadgeLevels[Stage]}] - " + Value.Value);
            }
        }
예제 #5
0
파일: Player.cs 프로젝트: CamuiChan/ACSE
        public void Write()
        {
            Type PlayerSaveInfoType = typeof(PlayerSaveInfo);
            Type PlayerDataType     = typeof(PlayerData);

            foreach (var Field in PlayerSaveInfoType.GetFields(BindingFlags.Public | BindingFlags.Instance))
            {
                if (Field.GetValue(Offsets) != null && !Field.Name.Contains("Count") && !Field.Name.Contains("Size"))
                {
                    if (PlayerDataType.GetField(Field.Name) != null)
                    {
                        if (Field.FieldType == typeof(int) && (int)Field.GetValue(Offsets) != -1)
                        {
                            Type FieldType  = typeof(PlayerData).GetField(Field.Name).FieldType;
                            int  DataOffset = Offset + (int)Field.GetValue(Offsets);
                            //MessageBox.Show("Field Name: " + Field.Name + " | Data Offset: " + DataOffset.ToString("X"));
                            if (Field.Name == "TownPassCardImage" && (SaveData.Save_Type == SaveType.New_Leaf || SaveData.Save_Type == SaveType.Welcome_Amiibo))
                            {
                                SaveData.Write(DataOffset, Data.TownPassCardData);
                            }
                            else if (FieldType == typeof(string))
                            {
                                SaveData.Write(DataOffset, ACString.GetBytes((string)PlayerDataType.GetField(Field.Name).GetValue(Data),
                                                                             (int)PlayerSaveInfoType.GetField(Field.Name + "Size").GetValue(Offsets)));
                            }
                            else if (FieldType == typeof(byte))
                            {
                                if (SaveData.Save_Type == SaveType.Wild_World)
                                {
                                    if (Field.Name == "HairColor")
                                    {
                                        byte Condensed_Data = (byte)(Data.HairColor & 0x0F); //Remove upper nibble just incase
                                        Condensed_Data += (byte)((Data.Tan & 0x0F) << 4);    //Add in tan to the byte
                                        SaveData.Write(DataOffset, Condensed_Data);
                                        //MessageBox.Show("HairColor: " + Condensed_Data.ToString("X2"));
                                    }
                                    else if (Field.Name == "HairType")
                                    {
                                        byte Condensed_Data = (byte)(Data.FaceType & 0x0F);
                                        Condensed_Data += (byte)((Data.HairType & 0x0F) << 4);
                                        SaveData.Write(DataOffset, Condensed_Data);
                                        //MessageBox.Show("HairType: " + Condensed_Data.ToString("X2"));
                                    }
                                    else
                                    {
                                        SaveData.Write(DataOffset, (byte)PlayerDataType.GetField(Field.Name).GetValue(Data));
                                        //MessageBox.Show("Hello! " + Field.Name + " Offset: " + DataOffset.ToString("X"));
                                    }
                                }
                                else if (SaveData.Save_Type == SaveType.City_Folk)
                                {
                                    if (Field.Name == "Tan")
                                    {
                                        byte Shifted_Data = (byte)(Data.Tan << 1); //ACToolkit does this
                                        SaveData.Write(DataOffset, Shifted_Data);
                                    }
                                    else if (Field.Name == "FaceType")
                                    {
                                        SaveData.Write(DataOffset, (byte)(Data.EyeColor + Data.FaceType));
                                    }
                                    else
                                    {
                                        SaveData.Write(DataOffset, (byte)PlayerDataType.GetField(Field.Name).GetValue(Data));
                                    }
                                }
                                else
                                {
                                    SaveData.Write(DataOffset, (byte)PlayerDataType.GetField(Field.Name).GetValue(Data));
                                }
                            }
                            else if (FieldType == typeof(ushort) || FieldType == typeof(uint))
                            {
                                SaveData.Write(DataOffset, (dynamic)PlayerDataType.GetField(Field.Name).GetValue(Data), SaveData.Is_Big_Endian);
                            }
                            else if (FieldType == typeof(Inventory))
                            {
                                if (SaveData.Save_Type == SaveType.New_Leaf || SaveData.Save_Type == SaveType.Welcome_Amiibo)
                                {
                                    uint[] Items = new uint[Offsets.PocketsCount];
                                    for (int i = 0; i < Items.Length; i++)
                                    {
                                        Items[i] = ItemData.EncodeItem(Data.Pockets.Items[i]);
                                    }
                                    SaveData.Write(DataOffset, Items);
                                }
                                else
                                {
                                    ushort[] Items = new ushort[Offsets.PocketsCount];
                                    for (int i = 0; i < Items.Length; i++)
                                    {
                                        Items[i] = Data.Pockets.Items[i].ItemID;
                                    }
                                    SaveData.Write(DataOffset, Items, SaveData.Is_Big_Endian);
                                }
                            }
                            else if (FieldType == typeof(NL_Int32))
                            {
                                if (SaveData.Save_Type == SaveType.New_Leaf || SaveData.Save_Type == SaveType.Welcome_Amiibo)
                                {
                                    NL_Int32 Encrypted_Int = (NL_Int32)PlayerDataType.GetField(Field.Name).GetValue(Data);
                                    SaveData.Write(DataOffset, Encrypted_Int.Int_1);
                                    SaveData.Write(DataOffset + 4, Encrypted_Int.Int_2);
                                }
                            }
                        }
                    }
                }
            }
        }