Ejemplo n.º 1
0
        private void pictureBox1_Click_1(object sender, EventArgs e)
        {
            using (OpenFileDialog o = new OpenFileDialog())
            {
                o.Title  = "Select a plugin (.json) file";
                o.Filter = "Pro Swapper Plugin (*.json)|*.json|All files (*.*)|*.*";
                if (o.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        string   filedata   = File.ReadAllText(o.FileName);
                        api.Item pluginitem = JsonConvert.DeserializeObject <api.Item>(filedata);

                        if (pluginitem.Zlib == true)
                        {
                            new ZlibSwap(pluginitem).ShowDialog();
                        }
                        else
                        {
                            new OodleSwap(pluginitem).ShowDialog();
                        }
                    }
                    catch
                    {
                        MessageBox.Show("That's not a valid plugin! Plugins must be in a Json format! Please read Plugins Tutorial for more information", "Pro Swapper", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public Lobby(UI.Splash splash)
        {
            InitializeComponent();
            string FNCosmeticsPath = global.ProSwapperFolder + "lobby.ProSwapper";

            Icon      = Main.appIcon;
            BackColor = global.MainMenu;


            CurrentCID = new Item();
            var asset = new Asset();

            asset.AssetPath = "FortniteGame/AssetRegistry.bin";
            asset.UcasFile  = "pakchunk0-WindowsClient.pak";//Asset registry is always in pakchunk0 coz ue4 moment
            asset.Search    = new string[1] {
                $""
            };
            asset.Replace = new string[1] {
                $""
            };
            CurrentCID.Asset = new Asset[1] {
                asset
            };

            if (global.allskins == null)
            {
                SkinSearch.Root allitems = new();
                download : double TimeNow = global.GetEpochTime();
                if (global.CurrentConfig.LobbyLastOpened + 86400 < TimeNow)
                {
                    //More than 24hrs have passed
                    allitems = msgpack.MsgPacklz4 <SkinSearch.Root>($"{api.FNAPIEndpoint}v2/cosmetics/br?responseFormat=msgpack_lz4&responseOptions=ignore_null");
                    File.WriteAllText(FNCosmeticsPath, JsonConvert.SerializeObject(allitems));
                    global.CurrentConfig.LobbyLastOpened = TimeNow;
                    global.SaveConfig();
                }
                else
                {
                    if (!File.Exists(FNCosmeticsPath))
                    {
                        global.CurrentConfig.LobbyLastOpened = 0;
                        goto download;
                    }
                    allitems = JsonConvert.DeserializeObject <SkinSearch.Root>(File.ReadAllText(FNCosmeticsPath));
                }


                global.allskins      = new SkinSearch.Root();
                global.allskins.data = allitems.data.Where(x => CIDSelection.actuallyUsingBackends.Any(x.type.backendValue.Equals)).ToArray();
            }
            splash.Invoke(new Action(() => { splash.Close(); }));
        }
Ejemplo n.º 3
0
 public GridItem(api.Item i)
 {
     InitializeComponent();
     backgroundWorker1.DoWork += delegate
     {
         pictureBox1.Image = global.ItemIcon(i.ToImage);
     };
     backgroundWorker1.RunWorkerAsync();
     pictureBox1.Click += delegate
     {
         new OodleSwap(i).Show();
     };
     label1.Text = i.SwapsTo.Split('|')[0];
     backgroundWorker1.Dispose();
 }
Ejemplo n.º 4
0
        private void AddItem(api.Item item)
        {
            int        buttonx    = 154;
            int        buttony    = 161;
            PictureBox picturebox = new PictureBox
            {
                SizeMode = PictureBoxSizeMode.Zoom,
                Size     = new Size(buttonx, buttony),
                Cursor   = Cursors.Hand
            };

            picturebox.Click += delegate
            {
                new OodleSwap(item).Show();
                Close();
            };
            Label lbl = new Label
            {
                ForeColor = global.TextColor,
                Font      = new Font("Segoe UI", 7f, FontStyle.Regular),
                Location  = new Point(picturebox.Location.X, picturebox.Location.Y + 160),
                TextAlign = ContentAlignment.TopCenter,
                Anchor    = AnchorStyles.Top
            };


            if (IsSwapOption)
            {
                lbl.Text         = item.SwapsFrom;
                picturebox.Image = global.ItemIcon(item.FromImage);
            }
            else
            {
                lbl.Text         = item.SwapsTo;
                picturebox.Image = global.ItemIcon(item.ToImage);
            }
            Panel panel = new Panel
            {
                Size = new Size(buttonx + 10, buttony + 50)
            };

            panel.Controls.Add(picturebox);
            panel.Controls.Add(lbl);
            flowLayoutPanel1.Controls.Add(panel);
        }
Ejemplo n.º 5
0
        public ZlibSwap(api.Item item)
        {
            InitializeComponent();
            this.Icon = Main.appIcon;
            RPC.SetState(item.SwapsFrom + " To " + item.SwapsTo, true);
            ThisItem = item;
            string swaptext = ThisItem.SwapsFrom + " --> " + ThisItem.SwapsTo;

            Text            = swaptext;
            label1.Text     = swaptext;
            image.Image     = global.ItemIcon(ThisItem.FromImage);
            swapsfrom.Image = global.ItemIcon(ThisItem.ToImage);
            Region          = Region.FromHrgn(Main.CreateRoundRectRgn(0, 0, Width, Height, 30, 30));

            BackColor        = global.MainMenu;
            logbox.BackColor = global.MainMenu;

            ConvertB.ForeColor   = global.TextColor;
            ConvertB.BackColor   = global.Button;
            ConvertB.Activecolor = global.Button;
            ConvertB.Normalcolor = global.Button;


            RevertB.ForeColor   = global.TextColor;
            RevertB.BackColor   = global.Button;
            RevertB.Activecolor = global.Button;
            RevertB.Normalcolor = global.Button;

            logbox.ForeColor = global.TextColor;
            if (global.CurrentConfig.swaplogs.Contains(ThisItem.SwapsFrom + " To " + ThisItem.SwapsTo + " (Lobby),"))
            {
                label3.ForeColor = Color.Lime;
                label3.Text      = "ON";
            }
            else
            {
                label3.ForeColor = Color.Red;
                label3.Text      = "OFF";
                if (ThisItem.Note != null)
                {
                    MessageBox.Show("Warning for " + ThisItem.SwapsTo + ": " + ThisItem.Note, ThisItem.SwapsFrom + " - " + ThisItem.SwapsTo, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }
Ejemplo n.º 6
0
        public static bool SwapZlib(api.Item item, bool Converting)
        {
            const string ProSwapperPakFolder = "Pro Swapper Lobby";
            string       PaksLocation        = global.CurrentConfig.Paks;
            //Load the exporter
            List <string> thesefiles = new List <string>();

            foreach (var Asset in item.Asset)
            {
                thesefiles.Add(Path.GetFileNameWithoutExtension(Asset.UcasFile));
            }

            List <string> UsingFiles = thesefiles.Distinct().ToList();

            if (!global.CanSwap(UsingFiles))
            {
                return(false);
            }

            foreach (string file in UsingFiles)
            {
                string BaseFileName = $"{PaksLocation}\\{ProSwapperPakFolder}\\{file}";


                //Check if it may be old game version
                string OriginalSig = global.FileToMd5($"{PaksLocation}\\{file}.sig");
                string ModifiedSig = global.FileToMd5(BaseFileName + ".sig");
                if (OriginalSig != ModifiedSig)
                {
                    Lobby.RevertAllLobbySwaps();
                }


                if (!File.Exists(BaseFileName + ".pak"))
                {
                    Directory.CreateDirectory(PaksLocation + $"\\{ProSwapperPakFolder}");
                    File.Copy($"{PaksLocation}\\{file}.sig", BaseFileName + ".sig", true);
                    File.Copy($"{PaksLocation}\\{file}.utoc", BaseFileName + ".utoc", true);
                    File.Copy($"{PaksLocation}\\{file}.ucas", BaseFileName + ".ucas", true);
                    File.Copy($"{PaksLocation}\\{file}.pak", BaseFileName + ".pak", true);
                }
            }

            var Provider = new DefaultFileProvider($"{PaksLocation}\\{ProSwapperPakFolder}", SearchOption.TopDirectoryOnly);

            Provider.Initialize(UsingFiles);


            //Load all aes keys for required files, cleaner in linq than doing a loop
            Provider.UnloadedVfs.All(x => { Provider.SubmitKey(x.EncryptionKeyGuid, api.AESKey); return(true); });


            List <FinalPastes> finalPastes = new List <FinalPastes>();

            foreach (api.Asset asset in item.Asset)
            {
                string ucasfile = $"{PaksLocation}\\{ProSwapperPakFolder}\\{asset.UcasFile}";

                //Checking if file is readonly coz we wouldn't be able to do shit with it
                File.SetAttributes(ucasfile, global.RemoveAttribute(File.GetAttributes(ucasfile), FileAttributes.ReadOnly));

                foreach (string srch in asset.Search)
                {
                    SearchString = srch;

                    Fortnite.FortniteExport.ExportAsset(Provider, asset.UcasFile, asset.AssetPath);

                    byte[] edited = EditAsset(zlibblock.decompressed, asset, Converting, out bool Compress); //Compressed edited path

                    byte[] towrite = ByteCompression.Compress(edited);                                       //Compress to zlib

                    towrite = FillEnd(towrite, zlibblock.compressed.Length);

                    finalPastes.Add(new FinalPastes(ucasfile, towrite, zlibblock.BlockStart));
                }

                //                if (Converting)
                //                    SearchString = asset.Search[0];
                //                else
                //                    SearchString = asset.Replace[0];
                //                //Use this to define zlibblock var
                //                Fortnite.FortniteExport.ExportAsset(Provider, asset.UcasFile, asset.AssetPath);
                //#if DEBUG
                //                Directory.CreateDirectory("Exports");

                //                string smallname = Path.GetFileName(asset.AssetPath);
                //                File.WriteAllBytes($"Exports\\Exported_{smallname}.pak", zlibblock.decompressed);//Just simple export
                //                                                                                                 // File.WriteAllBytes($"Exports\\RawExport_{smallname}.pak", RawExported);//Uncompress exported by CUE4Parse

                //#endif
                //                //edit files and compress with oodle and replace
                //                byte[] edited = EditAsset(zlibblock.decompressed, asset, Converting, out bool Compress);//Compressed edited path
                //                if (!Compress)//File hasnt gotten any changes, no need to edit files that havent changed
                //                    continue;


                //                byte[] towrite = ByteCompression.Compress(edited);//Compress to zlib

                //                towrite = FillEnd(towrite, zlibblock.compressed.Length);
                //#if DEBUG
                //                //Logging stuff for devs hehe
                //                File.WriteAllBytes($"Exports\\Edited_{smallname}.pak", edited);//Edited export
                //                File.WriteAllBytes($"Exports\\Compressed{smallname}.pak", towrite);//Compressed edited export

                //#endif
                //                finalPastes.Add(new FinalPastes(ucasfile, towrite, zlibblock.BlockStart));
            }

            Provider.Dispose();
            foreach (FinalPastes pastes in finalPastes)
            {
                PasteInLocationBytes(pastes);
            }

            return(true);
        }
Ejemplo n.º 7
0
        public static bool SwapItem(api.Item item, bool Converting)
        {
            const string  ProSwapperPakFolder = ".ProSwapper";
            List <string> UsingFiles          = new List <string>();

            UsingFiles.AddRange(item.Asset.Select(x => Path.GetFileNameWithoutExtension(x.UcasFile)).Distinct());
            if (!global.CanSwap(UsingFiles))
            {
                return(false);
            }

            foreach (string file in UsingFiles)
            {
                string BaseFileName = $"{PaksLocation}\\{ProSwapperPakFolder}\\{file}";

                //Check if it may be old game version
                string OriginalSig = global.FileToMd5($"{PaksLocation}\\{file}.sig");
                string ModifiedSig = global.FileToMd5(BaseFileName + ".sig");
                if (OriginalSig != ModifiedSig)
                {
                    global.DeleteFile(BaseFileName + ".sig");
                    global.DeleteFile(BaseFileName + ".utoc");
                    global.DeleteFile(BaseFileName + ".ucas");
                    global.DeleteFile(BaseFileName + ".pak");
                }


                if (!File.Exists(BaseFileName + ".ucas"))
                {
                    Directory.CreateDirectory(PaksLocation + $"\\{ProSwapperPakFolder}");
                    File.Copy($"{PaksLocation}\\{file}.sig", BaseFileName + ".sig", true);
                    File.Copy($"{PaksLocation}\\{file}.utoc", BaseFileName + ".utoc", true);
                    File.Copy($"{PaksLocation}\\{file}.ucas", BaseFileName + ".ucas", true);
                    File.Copy($"{PaksLocation}\\{file}.pak", BaseFileName + ".pak", true);
                }
            }

            var Provider = new DefaultFileProvider($"{PaksLocation}\\{ProSwapperPakFolder}", SearchOption.TopDirectoryOnly);

            Provider.Initialize(UsingFiles);

            //Load all aes keys for required files, cleaner in linq than doing a loop
            Provider.UnloadedVfs.All(x => { Provider.SubmitKey(x.EncryptionKeyGuid, api.AESKey); return(true); });

            List <FinalPastes> finalPastes = new List <FinalPastes>();

            foreach (api.Asset asset in item.Asset)
            {
                string ucasfile = $"{PaksLocation}\\{ProSwapperPakFolder}\\{asset.UcasFile}";
                File.SetAttributes(ucasfile, global.RemoveAttribute(File.GetAttributes(ucasfile), FileAttributes.ReadOnly));
                byte[] exportasset = Fortnite.FortniteExport.ExportAsset(Provider, asset.UcasFile, asset.AssetPath);
                // Directory.CreateDirectory("Exports");

                string smallname = Path.GetFileName(asset.AssetPath);
#if DEBUG
                File.WriteAllBytes($"Exports\\Exported_{smallname}.pak", exportasset);//Just simple export
#endif
                if (EditAsset(ref exportasset, asset, Converting))
                {
#if DEBUG
                    File.WriteAllBytes($"Exports\\Edited_{smallname}.pak", exportasset);//Edited export
#endif
                    exportasset = Oodle.OodleClass.Compress(exportasset);
                    //Logging stuff for devs hehe
                    // File.WriteAllBytes($"Exports\\Compressed{smallname}.pak", exportasset);//Compressed edited export
                    finalPastes.Add(new FinalPastes(ucasfile, exportasset, Fortnite.FortniteExport.Offset));
                }
            }
            Provider.Dispose();
            foreach (FinalPastes pastes in finalPastes)
            {
                PasteInLocationBytes(pastes);
            }

            return(true);
        }