Ejemplo n.º 1
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.º 2
0
        public Main(UI.Splash splash)
        {
            InitializeComponent();
            Mainform = this;
            try
            {
                api.UpdateAPI();
                string apiversion = api.apidata.version;
                double TimeNow    = global.GetEpochTime();

                if (global.CurrentConfig.lastopened + 7200 < TimeNow)
                {
                    global.OpenUrl(api.apidata.discordurl);
                    global.CurrentConfig.lastopened = TimeNow;
                }

                int thisVer = int.Parse(global.version.Replace(".", ""));
                int apiVer  = int.Parse(api.apidata.version.Replace(".", ""));

                const string NewDownload = "https://linkvertise.com/86737/proswapper";

                if (apiVer > thisVer)
                {
                    MessageBox.Show("New Pro Swapper Update found! Redirecting you to the new download!", "Pro Swapper Update", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    global.OpenUrl(NewDownload);
                    Cleanup();
                }

                if (global.IsNameModified())
                {
                    ThrowError($"This Pro Swapper version has been renamed, this means you have not downloaded it from the official source. Please redownload it on the Discord server at {api.apidata.discordurl}");
                    global.OpenUrl(NewDownload);
                }

                if (api.apidata.status[0].IsUp == false)
                {
                    ThrowError(api.apidata.status[0].DownMsg);
                }

                Color[] theme = global.CurrentConfig.theme;
                global.MainMenu  = theme[0];
                global.ItemsBG   = theme[1];
                global.Button    = theme[2];
                global.TextColor = theme[3];
                RPC.InitializeRPC();

                Icon              = appIcon;
                Region            = Region.FromHrgn(CreateRoundRectRgn(0, 0, Width, Height, 30, 30));
                versionlabel.Text = global.version;

                panelContainer.Controls.Add(Dashboard.Instance);
                Control.ControlCollection MenuButtons = Controls["panel1"].Controls;
                for (int i = 0; i < MenuButtons.Count; i++)
                {
                    if (MenuButtons[i].GetType().Name == "BunifuFlatButton" && MenuButtons[i].Tag.Equals("TabButton"))
                    {
                        BunifuFlatButton btn = (BunifuFlatButton)MenuButtons[i];
                        btn.BackColor = btn.Normalcolor = btn.OnHovercolor = btn.Activecolor = global.Button;
                        btn.Textcolor = btn.OnHoverTextColor = global.TextColor;
                        if (btn.Text == "Settings")
                        {
                            continue;
                        }

                        btn.Click += delegate
                        {
                            NewPanel(btn.Text);
                        };
                    }
                }

                BackColor              = global.MainMenu;
                panel1.BackColor       = global.MainMenu;
                versionlabel.ForeColor = global.TextColor;
                global.SaveConfig();
                splash.Invoke(new Action(() => { splash.Close(); }));
            }
            catch (Exception ex)
            {
                Program.logger.LogError(ex.Message);
                ThrowError($"Source: {ex.Source} | Message: {ex.Message} | Stack Trace: {ex.StackTrace}", true);
            }
        }