Exemple #1
0
 private void btnedit_Click(object sender, EventArgs e)
 {
     if (lvmypackages.SelectedItems.Count > 0)
     {
         ListViewItem    itm = lvmypackages.SelectedItems[0];
         AppscapePackage pkg = (AppscapePackage)itm.Tag;
         PackageToEdit = pkg;
         pnlpackageeditor.BringToFront();
         SetupEditor();
     }
 }
Exemple #2
0
 /// <summary>
 /// Uploads a new package to the server.
 /// </summary>
 /// <param name="pkgMeta">Package metadata (name, description, etc)</param>
 /// <param name="pkg">Byte array representing the .stp file to upload.</param>
 public void UploadPackage(AppscapePackage pkgMeta, byte[] pkg)
 {
     pkgMeta.SetupFile = pkgMeta.Name.Replace(" ", "_") + ".stp";
     Package_Grabber.SendMessage(_IP, $"apm uploadmeta {pkgMeta.Name.Replace(" ", "_")}.json", pkgMeta);
     Package_Grabber.SendMessage(_IP, $"apm upload {pkgMeta.SetupFile}", pkg);
 }
Exemple #3
0
        private void lvpackages_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lvpackages.SelectedItems.Count > 0)
            {
                lvpackages.SelectedItems[0].BackColor = Color.Gray;
                pnldownload.Show();
                foreach (ListViewItem lv in lvpackages.Items)
                {
                    lv.BackColor = Color.White;
                }
                if (DataType == "apps")
                {
                    AppscapePackage pkg = (AppscapePackage)lvpackages.SelectedItems[0].Tag;
                    lbpkgname.Text        = pkg.Name;
                    lbpkgdescription.Text = pkg.Description;
                    try {
                        pbappscreenshot.Show();
                        pbappscreenshot.Load(pkg.ScreenshotPath);
                    }
                    catch (Exception ex)
                    {
                        pbappscreenshot.Hide();
                    }
                    if (pkg.SetupFile == "" || pkg.SetupFile == null)
                    {
                        pnldownload.Hide();
                    }
                    else
                    {
                        pnldownload.Show();
                        lbdownloadpath.Text = "This package will download to: " + pkg.Name + ".stp.";
                        if (!pkg.SetupFile.EndsWith(".stp"))
                        {
                            pkg.SetupFile = pkg.SetupFile + ".stp";
                        }

                        foreach (var c in clients)
                        {
                            if (c.IP == pkg.Server)
                            {
                                DownloadClient = c;
                            }
                        }
                        DownloadPath = pkg.SetupFile;
                    }
                    try {
                        pbappicon.Show();
                        pbappicon.Load("http://playshiftos.ml/appscape/packages/" + pkg.PkgIconPath);
                    }
                    catch (Exception ex)
                    {
                        pbappicon.Hide();
                    }
                    if (pkg.Cost == 0)
                    {
                        CurrentItemCost = Convert.ToDecimal(pkg.Cost);
                    }
                    else
                    {
                        CurrentItemCost = Convert.ToDecimal(pkg.Cost.ToString("#.#####"));
                    }
                    if (pkg.DevKey != null)
                    {
                        pnlauthordetails.Show();
                        lbauthorname.Text        = "Author: " + GetModderByDevID(pkg.DevKey).Key.Name;
                        lbauthordescription.Text = GetModderByDevID(pkg.DevKey).Key.Bio;
                        AddressToSendTo          = GetModderByDevID(pkg.DevKey).Key.BitnoteAddress;
                    }
                    else
                    {
                        pnlauthordetails.Hide();
                        //Classic packages.
                        if (pkg.Address != null)
                        {
                            AddressToSendTo = pkg.Address;
                        }
                        else
                        {
                            AddressToSendTo = null;
                        }
                    }
                }
                else
                {
                    var skin = (SkinData)lvpackages.SelectedItems[0].Tag;
                    lbpkgname.Text        = skin.Name;
                    lbpkgdescription.Text = "Author: " + skin.Author + Environment.NewLine;
                    if (skin.Download.EndsWith(".skn"))
                    {
                        lbpkgdescription.Text += "Type: Single Skin (.skn)" + Environment.NewLine;
                    }
                    else
                    {
                        lbpkgdescription.Text += "Type: Skin Pack (.spk)" + Environment.NewLine;
                    }
                    if (skin.Screenshot != null)
                    {
                        pbappscreenshot.Show();
                        pbappscreenshot.Load(skin.Screenshot);
                    }
                    else
                    {
                        pbappscreenshot.Hide();
                    }
                    if (skin.Icon != null)
                    {
                        pbappicon.Show();
                        pbappicon.Load("http://shiftos.shiftgames.ml/appscape/skins/" + skin.Icon);
                    }
                    else
                    {
                        pbappicon.Hide();
                    }
                    if (skin.Cost == 0)
                    {
                        CurrentItemCost = Convert.ToDecimal(skin.Cost);
                    }
                    else
                    {
                        CurrentItemCost = Convert.ToDecimal(skin.Cost.ToString("#.#####"));
                    }
                    lbpkgdescription.Text += Environment.NewLine + skin.Description;
                    lbdownloadpath.Text    = "This skin will download to C:\\ShiftOS\\Home\\Downloads\\" + skin.Download;
                    foreach (var c in clients)
                    {
                        if (c.IP == skin.Server)
                        {
                            DownloadClient = c;
                        }
                    }
                    DownloadPath = skin.Download;
                }
            }
        }
        private void btndone_Click(object sender, EventArgs e)
        {
            bool ContinueUpload = true;
            //Create new package and assign values
            var pkg = new AppscapePackage();

            pkg.Name        = txtpackagename.Text;
            pkg.DevKey      = MyProfile.DevKey;
            pkg.Description = txtpackagedescription.Text;
            if (cbsell.Checked == true)
            {
                try
                {
                    pkg.Cost = Convert.ToDecimal(Convert.ToDecimal(txtprice.Text).ToString("#.#####"));
                }
                catch (Exception ex)
                {
                    ContinueUpload = false;
                    API.CreateInfoboxSession("Error", "You have entered an incorrect price value.", infobox.InfoboxMode.Info);
                }
            }
            else
            {
                pkg.Cost = 0;
            }
            pkg.SetupFile   = pkg.Name.Replace(" ", "_");
            pkg.PkgIconPath = "";
            if (AppScreenshot != null)
            {
                pkg.ScreenshotPath = new FileInfo(AppScreenshot).Name.Replace(" ", "_");
            }
            else
            {
                pkg.ScreenshotPath = "none.jpg";
            }
            if (ContinueUpload == true)
            {
                //Upload the package meta file

                if (!Directory.Exists(Paths.Mod_Temp + "newapm"))
                {
                    Directory.CreateDirectory(Paths.Mod_Temp + "newapm");
                }
                else
                {
                    Directory.Delete(Paths.Mod_Temp + "newapm", true);
                    Directory.CreateDirectory(Paths.Mod_Temp + "newapm");
                }

                //Copy app SAA and icon to package folder
                File.Copy(SAAFile, Paths.Mod_Temp + "newapm" + OSInfo.DirectorySeparator + "app.saa");
                if (AppIcon != null)
                {
                    File.Copy(AppIcon, Paths.Mod_Temp + "newapm" + OSInfo.DirectorySeparator + "Icon.bmp");
                }
                else
                {
                    Properties.Resources.iconShiftnet.Save(Paths.Mod_Temp + "newapm" + OSInfo.DirectorySeparator + "Icon.bmp");
                }

                //Create AL meta file for package (so it will display in the app launcher)
                var al = new ModApplauncherItem();
                al.Display      = true;
                al.Icon         = "Icon.bmp";
                al.Name         = pkg.Name;
                al.ShiftCode    = "runSAA:app.saa";
                al.AppDirectory = al.Name;

                //Serialize AL meta file and copy to package
                var json = JsonConvert.SerializeObject(al);
                File.WriteAllText(Paths.Mod_Temp + "newapm" + OSInfo.DirectorySeparator + "applauncher", json);

                //Package file to .stp and upload to Appscape
                ZipFile.CreateFromDirectory(Paths.Mod_Temp + "newapm", Paths.Mod_Temp + pkg.Name.Replace(" ", "_") + ".stp");
                Repo.UploadPackage(pkg, File.ReadAllBytes(Paths.Mod_Temp + pkg.Name.Replace(" ", "_") + ".stp"));



                result = "finished";
                this.Close();
            }
        }