mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-05-25 11:16:20 +00:00
Merge main into pck_cleanup_and_refactor
This commit is contained in:
111
MinecraftUSkinEditor/Classes/API/PCKCenter/SaveLocalJSON.cs
Normal file
111
MinecraftUSkinEditor/Classes/API/PCKCenter/SaveLocalJSON.cs
Normal file
@@ -0,0 +1,111 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using API.PCKCenter.model;
|
||||
|
||||
namespace API.PCKCenter
|
||||
{
|
||||
public class LocalActions
|
||||
{
|
||||
string cache = PckStudio.Program.Appdata + "cache/packs/";
|
||||
public bool SaveLocalJSON(PCKCenterJSON JSONData, string category, bool isVita)
|
||||
{
|
||||
try
|
||||
{
|
||||
string outputString = JsonConvert.SerializeObject(JSONData, Formatting.Indented);
|
||||
|
||||
switch (isVita)
|
||||
{
|
||||
case false:
|
||||
File.WriteAllText(cache + "normal/" + category + ".json", outputString);
|
||||
break;
|
||||
case true:
|
||||
File.WriteAllText(cache + "vita/" + category + ".json", outputString);
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public PCKCenterJSON GetLocalJSON(string category, bool isVita)
|
||||
{
|
||||
try
|
||||
{
|
||||
string JSONData = "";
|
||||
switch (isVita)
|
||||
{
|
||||
case false:
|
||||
JSONData = File.ReadAllText(cache + "normal/" + category + ".json");
|
||||
break;
|
||||
case true:
|
||||
JSONData = File.ReadAllText(cache + "vita/" + category + ".json");
|
||||
break;
|
||||
}
|
||||
return JsonConvert.DeserializeObject<PCKCenterJSON>(JSONData);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
PCKCenterJSON JSONData = new PCKCenterJSON();
|
||||
JSONData.Data = new Dictionary<string, EntryInfo>();
|
||||
return JSONData;
|
||||
}
|
||||
}
|
||||
public PCKCenterJSON AddPack(PCKCenterJSON JSONData,EntryInfo EInfo, int PackID)
|
||||
{
|
||||
JSONData.Data.Add(PackID.ToString(), EInfo);
|
||||
return JSONData;
|
||||
}
|
||||
public PCKCenterJSON Removepack(PCKCenterJSON JSONData, int PackID)
|
||||
{
|
||||
JSONData.Data.Remove(PackID.ToString());
|
||||
return JSONData;
|
||||
}
|
||||
|
||||
public bool SaveLocalCategories(bool isVita)
|
||||
{
|
||||
try
|
||||
{
|
||||
List<string> Cats = new List<string>();
|
||||
string StringData = "";
|
||||
switch (isVita)
|
||||
{
|
||||
case false:
|
||||
foreach(string file in Directory.GetFiles(cache + "normal/"))
|
||||
{
|
||||
if (Path.GetExtension(file) == ".json")
|
||||
Cats.Add(Path.GetFileNameWithoutExtension(file));
|
||||
}
|
||||
StringData = JsonConvert.SerializeObject(Cats.ToArray(), Formatting.Indented);
|
||||
File.WriteAllText(cache + "Categiories.json", StringData);
|
||||
break;
|
||||
case true:
|
||||
foreach (string file in Directory.GetFiles(cache + "vita/"))
|
||||
{
|
||||
if (Path.GetExtension(file) == ".json")
|
||||
Cats.Add(Path.GetFileNameWithoutExtension(file));
|
||||
}
|
||||
StringData = JsonConvert.SerializeObject(Cats.ToArray(), Formatting.Indented);
|
||||
File.WriteAllText(cache + "VitaCategiories.json", StringData);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace API.PCKCenter.model
|
||||
{
|
||||
public class PCKCenterJSON
|
||||
{
|
||||
public Dictionary<string, EntryInfo> Data { get; set; }
|
||||
}
|
||||
|
||||
public class EntryInfo
|
||||
{
|
||||
public string Name;
|
||||
public string Author;
|
||||
public string Description;
|
||||
}
|
||||
}
|
||||
@@ -5,40 +5,74 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Drawing;
|
||||
using Newtonsoft.Json;
|
||||
using API.PCKCenter.model;
|
||||
using API.PCKCenter;
|
||||
|
||||
namespace PckStudio.Classes.IO
|
||||
{
|
||||
public class PCKCollectionsLocal
|
||||
{
|
||||
string cache = Program.Appdata + "cache/packs/";
|
||||
public string[] GetLocalCategories()
|
||||
|
||||
public PCKCenterJSON CenterPacks;
|
||||
public LocalActions LocalAction = new LocalActions();
|
||||
|
||||
public string[] GetLocalCategories(bool isVita)
|
||||
{
|
||||
string cat = "";
|
||||
if (File.Exists(cache + "PCKCategories.txt"))
|
||||
cat = File.ReadAllText(cache + "PCKCategories.txt");
|
||||
return cat.Split(new[] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
|
||||
try
|
||||
{
|
||||
List<string> Cats = new List<string>();
|
||||
switch (isVita)
|
||||
{
|
||||
case false:
|
||||
foreach (string file in Directory.GetFiles(cache + "normal/"))
|
||||
{
|
||||
if (Path.GetExtension(file) == ".json")
|
||||
Cats.Add(Path.GetFileNameWithoutExtension(file));
|
||||
}
|
||||
break;
|
||||
case true:
|
||||
foreach (string file in Directory.GetFiles(cache + "vita/"))
|
||||
{
|
||||
if (Path.GetExtension(file) == ".json")
|
||||
Cats.Add(Path.GetFileNameWithoutExtension(file));
|
||||
}
|
||||
break;
|
||||
}
|
||||
return Cats.ToArray();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
return new string[] { };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public string[] GetLocalPackDescs(string Category, bool IsVita)
|
||||
public PCKCenterJSON GetLocalPackDescs(string Category, bool IsVita)
|
||||
{
|
||||
string cat = "";
|
||||
string StringData = "";
|
||||
try
|
||||
{
|
||||
switch (IsVita)
|
||||
{
|
||||
case (true):
|
||||
cat = File.ReadAllText(cache + "Category/VitaCategory" + Category + ".txt");
|
||||
StringData = File.ReadAllText(cache + "vita/ " + Category + ".json");
|
||||
break;
|
||||
case (false):
|
||||
cat = File.ReadAllText(cache + "Category/Category" + Category + ".txt");
|
||||
StringData = File.ReadAllText(cache + "normal/" + Category + ".json");
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.Message);
|
||||
return new PCKCenterJSON();
|
||||
}
|
||||
return cat.Split(new[] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
PCKCenterJSON Data = JsonConvert.DeserializeObject<PCKCenterJSON>(StringData);
|
||||
return Data;
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +121,7 @@ namespace PckStudio.Classes.IO
|
||||
}
|
||||
|
||||
|
||||
public Image GetLocalPackImage(string Category, bool IsVita)
|
||||
public Image GetLocalPackImage(int packID, bool IsVita)
|
||||
{
|
||||
Image image = null;
|
||||
try
|
||||
@@ -95,10 +129,10 @@ namespace PckStudio.Classes.IO
|
||||
switch (IsVita)
|
||||
{
|
||||
case (true):
|
||||
image = Image.FromFile(cache + "images/Vita/" + Category + ".png");
|
||||
image = Image.FromFile(cache + "vita/images/" + packID + ".png");
|
||||
break;
|
||||
case (false):
|
||||
image = Image.FromFile(cache + "images/" + Category + ".png");
|
||||
image = Image.FromFile(cache + "normal/images/" + packID + ".png");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,10 +10,10 @@ namespace PckStudio.Classes
|
||||
public static bool Beta = true;
|
||||
public static bool Portable = false;
|
||||
public static bool NeedsUpdate = false;
|
||||
public static string MainURL = "http://pckstudio.xyz/";
|
||||
public static string MainURL = "http://api.pckstudio.xyz/api/pck";
|
||||
public static string BackURL = "http://phoenixarc.ddns.net/";
|
||||
static string UpdateURL = "studio/PCK/api/updatePCKStudio.txt";
|
||||
static string BetaUpdateURL = "studio/PCK/api/updatePCKStudioB.txt";
|
||||
static string UpdateURL = "/update/Version";
|
||||
static string BetaUpdateURL = "/update/VersionBeta";
|
||||
|
||||
public static void CheckUpdate()
|
||||
{
|
||||
|
||||
@@ -8,6 +8,9 @@ using System.Threading.Tasks;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Drawing.Design;
|
||||
using System.Drawing;
|
||||
using Newtonsoft.Json;
|
||||
using API.PCKCenter.model;
|
||||
using API.PCKCenter;
|
||||
|
||||
namespace PckStudio.Classes.Networking
|
||||
{
|
||||
@@ -16,35 +19,34 @@ namespace PckStudio.Classes.Networking
|
||||
WebClient client = new WebClient();
|
||||
public string CurrentPackDl = "";
|
||||
string cache = Program.Appdata + "cache/packs/";
|
||||
public PCKCenterJSON CenterPacks;
|
||||
public LocalActions LocalAction = new LocalActions();
|
||||
public string[] GetCategories()
|
||||
{
|
||||
string cat = "";
|
||||
try
|
||||
{
|
||||
cat = client.DownloadString(PckStudio.Classes.Network.MainURL + "/studio/PCK/api/PCKCategories.txt");
|
||||
client.DownloadFile(PckStudio.Classes.Network.MainURL + "/studio/PCK/api/PCKCategories.txt", cache + "PCKCategories.txt");
|
||||
cat = client.DownloadString(Program.baseurl + "/center/packs/Categiories.json");
|
||||
}
|
||||
catch
|
||||
{
|
||||
cat = client.DownloadString(PckStudio.Classes.Network.BackURL + "/studio/PCK/api/PCKCategories.txt");
|
||||
client.DownloadFile(PckStudio.Classes.Network.BackURL + "/studio/PCK/api/PCKCategories.txt", cache + "PCKCategories.txt");
|
||||
cat = client.DownloadString(Program.baseurl + "/center/packs/VitaCategiories.json");
|
||||
}
|
||||
return cat.Split(new[] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
|
||||
return JsonConvert.DeserializeObject<string[]>(cat);
|
||||
}
|
||||
|
||||
public string[] GetPackDescs(string Category, bool IsVita)
|
||||
public PCKCenterJSON GetPackDescs(string Category, bool IsVita)
|
||||
{
|
||||
string cat = "";
|
||||
try
|
||||
{
|
||||
Console.WriteLine(PckStudio.Classes.Network.MainURL + "/studio/PCK/api/Category/Category" + Category + ".txt");
|
||||
switch (IsVita)
|
||||
{
|
||||
case (true):
|
||||
cat = client.DownloadString(PckStudio.Classes.Network.MainURL + "/studio/PCK/api/Category/VitaCategory" + Category + ".txt");
|
||||
cat = client.DownloadString(Program.baseurl + "/center/packs/vita/" + Category + ".json");
|
||||
break;
|
||||
case (false):
|
||||
cat = client.DownloadString(PckStudio.Classes.Network.MainURL + "/studio/PCK/api/Category/Category" + Category + ".txt");
|
||||
cat = client.DownloadString(Program.baseurl + "/center/packs/normal/" + Category + ".json");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -53,48 +55,17 @@ namespace PckStudio.Classes.Networking
|
||||
switch (IsVita)
|
||||
{
|
||||
case (true):
|
||||
cat = client.DownloadString(PckStudio.Classes.Network.BackURL + "/studio/PCK/api/Category/VitaCategory" + Category + ".txt");
|
||||
cat = client.DownloadString(Program.backurl + "/center/packs/vita/" + Category + ".json");
|
||||
break;
|
||||
case (false):
|
||||
cat = client.DownloadString(PckStudio.Classes.Network.BackURL + "/studio/PCK/api/Category/Category" + Category + ".txt");
|
||||
cat = client.DownloadString(Program.backurl + "/center/packs/normal/" + Category + ".json");
|
||||
break;
|
||||
}
|
||||
}
|
||||
return cat.Split(new[] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
|
||||
}
|
||||
|
||||
public string GetPackName(string Category, bool IsVita)
|
||||
{
|
||||
string cat = "";
|
||||
try
|
||||
{
|
||||
Console.WriteLine(PckStudio.Classes.Network.MainURL + "/studio/PCK/api/pcks/" + Category + ".desc");
|
||||
switch (IsVita)
|
||||
{
|
||||
case (true):
|
||||
cat = client.DownloadString(PckStudio.Classes.Network.MainURL + "/studio/PCK/api/pcks/Vita/" + Category + ".desc");
|
||||
break;
|
||||
case (false):
|
||||
cat = client.DownloadString(PckStudio.Classes.Network.MainURL + "/studio/PCK/api/pcks/" + Category + ".desc");
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch(Exception err)
|
||||
{
|
||||
switch (IsVita)
|
||||
{
|
||||
case (true):
|
||||
cat = client.DownloadString(PckStudio.Classes.Network.BackURL + "/studio/PCK/api/pcks/Vita/" + Category + ".desc");
|
||||
break;
|
||||
case (false):
|
||||
cat = client.DownloadString(PckStudio.Classes.Network.BackURL + "/studio/PCK/api/pcks/" + Category + ".desc");
|
||||
break;
|
||||
}
|
||||
}
|
||||
string[] data = cat.Split(new[] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
|
||||
return data[0];
|
||||
PCKCenterJSON Data = JsonConvert.DeserializeObject<PCKCenterJSON>(cat);
|
||||
return Data;
|
||||
}
|
||||
|
||||
public string[] GetPackData(string Category, bool IsVita)
|
||||
{
|
||||
string cat = "";
|
||||
@@ -125,7 +96,7 @@ namespace PckStudio.Classes.Networking
|
||||
return cat.Split(new[] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
|
||||
}
|
||||
|
||||
public Image GetPackImage(string Category, bool IsVita)
|
||||
public Image GetPackImage(int packID, bool IsVita)
|
||||
{
|
||||
byte[] cat = new byte[] { };
|
||||
try
|
||||
@@ -133,10 +104,10 @@ namespace PckStudio.Classes.Networking
|
||||
switch (IsVita)
|
||||
{
|
||||
case (true):
|
||||
cat = client.DownloadData(PckStudio.Classes.Network.MainURL + "/studio/PCK/api/pcks/Vita/image/" + Category + ".png");
|
||||
cat = client.DownloadData(Program.baseurl + "/center/packs/vita/images/" + packID + ".png");
|
||||
break;
|
||||
case (false):
|
||||
cat = client.DownloadData(PckStudio.Classes.Network.MainURL + "/studio/PCK/api/pcks/image/" + Category + ".png");
|
||||
cat = client.DownloadData(Program.baseurl + "/center/packs/normal/images/" + packID + ".png");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -145,10 +116,10 @@ namespace PckStudio.Classes.Networking
|
||||
switch (IsVita)
|
||||
{
|
||||
case (true):
|
||||
cat = client.DownloadData(PckStudio.Classes.Network.BackURL + "/studio/PCK/api/pcks/Vita/image/" + Category + ".png");
|
||||
cat = client.DownloadData(Program.backurl + "/center/packs/vita/images/" + packID + ".png");
|
||||
break;
|
||||
case (false):
|
||||
cat = client.DownloadData(PckStudio.Classes.Network.BackURL + "/studio/PCK/api/pcks/image/" + Category + ".png");
|
||||
cat = client.DownloadData(Program.backurl + "/center/packs/normal/images/" + packID + ".png");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -160,37 +131,35 @@ namespace PckStudio.Classes.Networking
|
||||
return image;
|
||||
}
|
||||
|
||||
public bool TryDownloadPack(string Category, bool IsVita, string PackCat)
|
||||
public bool TryDownloadPack(int packID, bool IsVita, string Category)
|
||||
{
|
||||
try
|
||||
{
|
||||
string[] desc = GetPackData(Category, IsVita);
|
||||
Image image = GetPackImage(Category, IsVita);
|
||||
string DescPath = cache;
|
||||
Directory.CreateDirectory(cache + "descs/Vita/");
|
||||
Directory.CreateDirectory(cache + "images/Vita/");
|
||||
Directory.CreateDirectory(cache + "files/Vita/");
|
||||
Directory.CreateDirectory(cache + "Category/");
|
||||
|
||||
Image image = GetPackImage(packID, IsVita);
|
||||
string DescPath = cache;
|
||||
Directory.CreateDirectory(cache + "normal/");
|
||||
Directory.CreateDirectory(cache + "normal/images");
|
||||
Directory.CreateDirectory(cache + "normal/pcks");
|
||||
Directory.CreateDirectory(cache + "vita/");
|
||||
Directory.CreateDirectory(cache + "vita/images");
|
||||
Directory.CreateDirectory(cache + "vita/pcks");
|
||||
PCKCenterJSON Local = LocalAction.GetLocalJSON(Category, IsVita);
|
||||
switch (IsVita)
|
||||
{
|
||||
case (true):
|
||||
DescPath = cache + "descs/Vita/" + Category + ".desc";
|
||||
image.Save(cache + "images/Vita/" + Category + ".png");
|
||||
File.WriteAllText(DescPath, desc[0] + "\n" + desc[1] + "\n" + desc[2]);
|
||||
File.WriteAllText(cache + "Category/VitaCategory" + PackCat + ".txt", "\n"+ Category);
|
||||
byte[] bytes = client.DownloadData(desc[3]);
|
||||
File.WriteAllBytes(cache + "files/Vita/" + Category + ".pck", bytes);
|
||||
break;
|
||||
case (false):
|
||||
DescPath = cache + "descs/" + Category + ".desc";
|
||||
image.Save(cache + "images/" + Category + ".png");
|
||||
File.WriteAllText(DescPath, desc[0] + "\n" + desc[1] + "\n" + desc[2]);
|
||||
File.WriteAllText(cache + "Category/Category" + PackCat + ".txt", "\n" + Category);
|
||||
byte[] bytes2 = client.DownloadData(desc[3]);
|
||||
File.WriteAllBytes(cache + "files/" + Category + ".pck", bytes2);
|
||||
image.Save(cache + "normal/images/" + packID + ".png");
|
||||
client.DownloadFile(Program.baseurl + "/center/packs/normal/pcks/" + packID + ".pck", cache + "normal/pcks/" + packID + ".pck");
|
||||
break;
|
||||
case (true):
|
||||
image.Save(cache + "vita/images/" + packID + ".png");
|
||||
client.DownloadFile(Program.baseurl + "/center/packs/vita/pcks/" + packID + ".pck", cache + "vita/pcks/" + packID + ".pck");
|
||||
break;
|
||||
}
|
||||
Local = LocalAction.AddPack(Local, CenterPacks.Data[packID.ToString()], packID);
|
||||
LocalAction.SaveLocalJSON(Local, Category, IsVita);
|
||||
LocalAction.SaveLocalCategories(IsVita);
|
||||
/**/
|
||||
image.Dispose();
|
||||
return true;
|
||||
}
|
||||
@@ -200,6 +169,28 @@ namespace PckStudio.Classes.Networking
|
||||
}
|
||||
}
|
||||
|
||||
public void TryTestPackInfo(bool IsVita)
|
||||
{
|
||||
try
|
||||
{
|
||||
WebClient wc = new WebClient();
|
||||
string CategoryJSON = wc.DownloadString(Program.baseurl + "/center/packs/Categiories.json");
|
||||
string[] Categories = JsonConvert.DeserializeObject<string[]>(CategoryJSON);
|
||||
PCKCenterJSON Result = pk1(Categories[2]);
|
||||
Console.Write(""); // this is a breakpoint
|
||||
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.Write(""); // this is a breakpoint
|
||||
}
|
||||
}
|
||||
PCKCenterJSON pk1(string categorie)
|
||||
{
|
||||
WebClient wc = new WebClient();
|
||||
string DataJSON = wc.DownloadString(Program.baseurl + "/center/packs/normal/" + categorie + ".json");
|
||||
PCKCenterJSON Data = JsonConvert.DeserializeObject<PCKCenterJSON>(DataJSON);
|
||||
return Data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@ namespace PckStudio.Classes
|
||||
{
|
||||
class Update
|
||||
{
|
||||
static string UpdateURL = "Download/setup/PCKStudio-Setup.msi";
|
||||
static string BetaUpdateURL = "Download/setup/beta/PCKStudioBeta-Setup.msi";
|
||||
static string UpdateURL = "/Update/Download/setup/PCKStudio-Setup.msi";
|
||||
static string BetaUpdateURL = "/Update/Download/setup/beta/PCKStudioBeta-Setup.msi";
|
||||
|
||||
public static void UpdateProgram(bool Beta)
|
||||
{
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace PckStudio
|
||||
|
||||
static class Program
|
||||
{
|
||||
public static string baseurl = "https://www.pckstudio.xyz/studio/PCK/api/";
|
||||
public static string baseurl = "http://api.pckstudio.xyz/api/pck";
|
||||
public static string backurl = "https://raw.githubusercontent.com/PhoenixARC/pckstudio.tk/main/studio/PCK/api/";
|
||||
public static string Appdata = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "/PCK Studio/";
|
||||
/// <summary>
|
||||
|
||||
@@ -14,6 +14,8 @@ using MetroFramework.Forms;
|
||||
using RichPresenceClient;
|
||||
using PckStudio.Classes.Networking;
|
||||
using PckStudio.Classes.IO;
|
||||
using API.PCKCenter.model;
|
||||
using API.PCKCenter;
|
||||
|
||||
namespace PckStudio.Forms.Utilities
|
||||
{
|
||||
@@ -37,6 +39,7 @@ namespace PckStudio.Forms.Utilities
|
||||
|
||||
public PCKCollections Collections = new PCKCollections();
|
||||
public PCKCollectionsLocal LocalCollections = new PCKCollectionsLocal();
|
||||
LocalActions LActions = new LocalActions();
|
||||
|
||||
string cache = Program.Appdata + "cache/";
|
||||
|
||||
@@ -57,7 +60,7 @@ namespace PckStudio.Forms.Utilities
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
string[] CatsL = LocalCollections.GetLocalCategories();
|
||||
string[] CatsL = LocalCollections.GetLocalCategories(VitaCheckBox2.Checked);
|
||||
foreach (string cat in CatsL)
|
||||
{
|
||||
CategoryComboBoxLocal.Items.Add(cat);
|
||||
@@ -78,53 +81,43 @@ namespace PckStudio.Forms.Utilities
|
||||
switch (metroTabControl1.SelectedIndex)
|
||||
{
|
||||
case 0:
|
||||
switch (VitaCheckBox.Checked)
|
||||
|
||||
PCKCenterJSON packs = Collections.GetPackDescs(CategoryComboBox.Text, VitaCheckBox.Checked);
|
||||
Collections.CenterPacks = packs;
|
||||
foreach (KeyValuePair<string, EntryInfo> entry in packs.Data)
|
||||
{
|
||||
case true:
|
||||
string[] packsVita = Collections.GetPackDescs(CategoryComboBox.Text, true);
|
||||
foreach (string pack in packsVita)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(pack) && !string.IsNullOrEmpty(pack))
|
||||
OnlineTreeView.Nodes.Add(Collections.GetPackName(pack, true));
|
||||
}
|
||||
break;
|
||||
case false:
|
||||
string[] packs = Collections.GetPackDescs(CategoryComboBox.Text, false);
|
||||
foreach (string pack in packs)
|
||||
{
|
||||
if(!string.IsNullOrWhiteSpace(pack) && !string.IsNullOrEmpty(pack))
|
||||
OnlineTreeView.Nodes.Add(Collections.GetPackName(pack, false));
|
||||
}
|
||||
break;
|
||||
TreeNode tn = new TreeNode(entry.Value.Name);
|
||||
tn.Tag = entry.Key;
|
||||
OnlineTreeView.Nodes.Add(tn);
|
||||
}
|
||||
|
||||
break;
|
||||
case 1:
|
||||
switch (VitaCheckBox2.Checked)
|
||||
|
||||
PCKCenterJSON Localpacks = LocalCollections.GetLocalPackDescs(CategoryComboBoxLocal.Text, VitaCheckBox2.Checked);
|
||||
LocalCollections.CenterPacks = Localpacks;
|
||||
foreach (KeyValuePair<string, EntryInfo> entry in Localpacks.Data)
|
||||
{
|
||||
case true:
|
||||
string[] packsVita = LocalCollections.GetLocalPackDescs(CategoryComboBoxLocal.Text, true);
|
||||
foreach (string pack in packsVita)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(pack) && !string.IsNullOrEmpty(pack))
|
||||
LocalTreeView.Nodes.Add(LocalCollections.GetLocalPackName(pack, true));
|
||||
}
|
||||
break;
|
||||
case false:
|
||||
string[] packs = LocalCollections.GetLocalPackDescs(CategoryComboBoxLocal.Text, false);
|
||||
foreach (string pack in packs)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(pack) && !string.IsNullOrEmpty(pack))
|
||||
LocalTreeView.Nodes.Add(LocalCollections.GetLocalPackName(pack, false));
|
||||
}
|
||||
break;
|
||||
TreeNode tn = new TreeNode(entry.Value.Name);
|
||||
tn.Tag = entry.Key;
|
||||
LocalTreeView.Nodes.Add(tn);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsPackLocal(string PackFile, bool IsVita)
|
||||
public bool IsPackLocal(int PackID, bool IsVita)
|
||||
{
|
||||
return File.Exists(cache + "packs/files/" + (IsVita ? "Vita/" : "") + PackFile + ".pck");
|
||||
switch (IsVita)
|
||||
{
|
||||
case true:
|
||||
return File.Exists(cache + "packs/vita/pcks/" + PackID + ".pck");
|
||||
break;
|
||||
case false:
|
||||
return File.Exists(cache + "packs/normal/pcks/" + PackID + ".pck");
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -133,20 +126,19 @@ namespace PckStudio.Forms.Utilities
|
||||
{
|
||||
try
|
||||
{
|
||||
string nam = "Pack Name: %n\nAuthor: %a\nDescription: %d";
|
||||
string[] packs = Collections.GetPackDescs(CategoryComboBox.Text, VitaCheckBox.Checked);
|
||||
string[] Data = Collections.GetPackData(packs[OnlineTreeView.SelectedNode.Index], VitaCheckBox.Checked);
|
||||
string nam = "Pack Name: %n\npack ID: %pid\nAuthor: %a\nDescription: %d";
|
||||
EntryInfo EI = Collections.CenterPacks.Data[OnlineTreeView.SelectedNode.Tag.ToString()];
|
||||
|
||||
metroLabel1.Text = nam.Replace("%n", Data[0]).Replace("%a", Data[1]).Replace("%d", Data[2]);
|
||||
metroLabel1.Text = nam.Replace("%n", EI.Name).Replace("%a", EI.Author).Replace("%d", EI.Description).Replace("%pid", OnlineTreeView.SelectedNode.Tag.ToString());
|
||||
metroLabel1.AutoSize = false;
|
||||
metroLabel1.WrapToLine = true;
|
||||
|
||||
pictureBox1.Image = Collections.GetPackImage(packs[OnlineTreeView.SelectedNode.Index], VitaCheckBox.Checked);
|
||||
pictureBox1.Image = Collections.GetPackImage(int.Parse(OnlineTreeView.SelectedNode.Tag.ToString()), VitaCheckBox.Checked);
|
||||
|
||||
if(!IsPackLocal(packs[OnlineTreeView.SelectedNode.Index], VitaCheckBox.Checked))
|
||||
if(!IsPackLocal(int.Parse(OnlineTreeView.SelectedNode.Tag.ToString()), VitaCheckBox.Checked))
|
||||
DownloadButton.Visible = true;
|
||||
else
|
||||
DownloadButton.Visible = false;
|
||||
DownloadButton.Visible = false;/**/
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -170,9 +162,8 @@ namespace PckStudio.Forms.Utilities
|
||||
{
|
||||
try
|
||||
{
|
||||
string[] packs = Collections.GetPackDescs(CategoryComboBox.Text, VitaCheckBox.Checked);
|
||||
Collections.TryDownloadPack(packs[OnlineTreeView.SelectedNode.Index], VitaCheckBox.Checked, CategoryComboBox.Text);
|
||||
MessageBox.Show("Download complete");
|
||||
Collections.TryDownloadPack(int.Parse(OnlineTreeView.SelectedNode.Tag.ToString()), VitaCheckBox.Checked, CategoryComboBox.Text);
|
||||
MessageBox.Show("Download complete");/**/
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -189,15 +180,14 @@ namespace PckStudio.Forms.Utilities
|
||||
|
||||
try
|
||||
{
|
||||
string nam = "Pack Name: %n\nAuthor: %a\nDescription: %d";
|
||||
string[] packs = LocalCollections.GetLocalPackDescs(CategoryComboBoxLocal.Text, VitaCheckBox2.Checked);
|
||||
string[] Data = LocalCollections.GetLocalPackData(packs[LocalTreeView.SelectedNode.Index], VitaCheckBox2.Checked);
|
||||
string nam = "Pack Name: %n\npack ID: %pid\nAuthor: %a\nDescription: %d";
|
||||
EntryInfo EI = LocalCollections.CenterPacks.Data[LocalTreeView.SelectedNode.Tag.ToString()];
|
||||
|
||||
metroLabel2.Text = nam.Replace("%n", Data[0]).Replace("%a", Data[1]).Replace("%d", Data[2]);
|
||||
metroLabel2.Text = nam.Replace("%n", EI.Name).Replace("%a", EI.Author).Replace("%d", EI.Description).Replace("%pid", LocalTreeView.SelectedNode.Tag.ToString());
|
||||
metroLabel2.AutoSize = false;
|
||||
metroLabel2.WrapToLine = true;
|
||||
|
||||
pictureBox2.Image = LocalCollections.GetLocalPackImage(packs[LocalTreeView.SelectedNode.Index], VitaCheckBox2.Checked);
|
||||
pictureBox2.Image = LocalCollections.GetLocalPackImage(int.Parse(LocalTreeView.SelectedNode.Tag.ToString()), VitaCheckBox2.Checked);
|
||||
OpenFolderButton.Visible = true;
|
||||
DeleteLocalButton.Visible = true;
|
||||
}
|
||||
@@ -240,15 +230,16 @@ namespace PckStudio.Forms.Utilities
|
||||
case true:
|
||||
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo()
|
||||
{
|
||||
FileName = Program.Appdata + "cache/packs/files/vita",
|
||||
FileName = cache + "packs/vita/pcks",
|
||||
UseShellExecute = true,
|
||||
Verb = "open"
|
||||
});
|
||||
break;
|
||||
case false:
|
||||
Console.WriteLine(cache + "packs/normal/pcks/");
|
||||
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo()
|
||||
{
|
||||
FileName = Program.Appdata + "cache/packs/files",
|
||||
FileName = cache + "packs/normal/pcks/",
|
||||
UseShellExecute = true,
|
||||
Verb = "open"
|
||||
});
|
||||
@@ -258,37 +249,29 @@ namespace PckStudio.Forms.Utilities
|
||||
|
||||
private void DeleteLocalButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
string[] packs = LocalCollections.GetLocalPackDescs(CategoryComboBoxLocal.Text, VitaCheckBox2.Checked);
|
||||
if (MessageBox.Show("Are you sure you would like to remove '" + packs[LocalTreeView.SelectedNode.Index] + "'?", "Confirmation Dialog", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
||||
EntryInfo EI = LocalCollections.CenterPacks.Data[LocalTreeView.SelectedNode.Tag.ToString()];
|
||||
string PackID = LocalTreeView.SelectedNode.Tag.ToString();
|
||||
LActions.Removepack(LocalCollections.CenterPacks, int.Parse(PackID));
|
||||
metroLabel2.Text = "Pack Name: %n\npack ID: %pid\nAuthor: %a\nDescription: %d";
|
||||
pictureBox2.Image.Dispose();
|
||||
pictureBox2.Image = Properties.Resources.NoImageFound;
|
||||
switch (VitaCheckBox2.Checked)
|
||||
{
|
||||
pictureBox2.Image = Properties.Resources.NoImageFound;
|
||||
switch (VitaCheckBox2.Checked)
|
||||
{
|
||||
case false:
|
||||
string FileInfo = File.ReadAllText(Program.Appdata + "cache/packs/Category/Category" + CategoryComboBoxLocal.Text + ".txt");
|
||||
File.Delete(Program.Appdata + "cache/packs/files/" + packs[LocalTreeView.SelectedNode.Index] + ".pck");
|
||||
File.Delete(Program.Appdata + "cache/packs/descs/" + packs[LocalTreeView.SelectedNode.Index] + ".desc");
|
||||
try
|
||||
{
|
||||
File.Delete(Program.Appdata + "cache/packs/images/" + packs[LocalTreeView.SelectedNode.Index] + ".png");
|
||||
}
|
||||
catch { }
|
||||
File.WriteAllText(Program.Appdata + "cache/packs/Category/Category" + CategoryComboBoxLocal.Text + ".txt", FileInfo.Replace("\n" + packs[LocalTreeView.SelectedNode.Index], ""));
|
||||
break;
|
||||
case true:
|
||||
string FileInfo2 = File.ReadAllText(Program.Appdata + "cache/packs/Category/VitaCategory" + CategoryComboBoxLocal.Text + ".txt");
|
||||
File.Delete(Program.Appdata + "cache/packs/files/Vita/" + packs[LocalTreeView.SelectedNode.Index] + ".pck");
|
||||
File.Delete(Program.Appdata + "cache/packs/descs/Vita/" + packs[LocalTreeView.SelectedNode.Index] + ".desc");
|
||||
try
|
||||
{
|
||||
File.Delete(Program.Appdata + "cache/packs/images/Vita/" + packs[LocalTreeView.SelectedNode.Index] + ".png");
|
||||
}
|
||||
catch { }
|
||||
File.WriteAllText(Program.Appdata + "cache/packs/Category/VitaCategory" + CategoryComboBoxLocal.Text + ".txt", FileInfo2.Replace("\n" + packs[LocalTreeView.SelectedNode.Index], ""));
|
||||
break;
|
||||
}
|
||||
LocalTreeView.SelectedNode.Remove();
|
||||
metroLabel2.Text = "Pack Name: %n\nAuthor: %a\nDescription: %d";
|
||||
case true:
|
||||
File.Delete(cache + "packs/vita/pcks/" + PackID + ".pck");
|
||||
File.Delete(cache + "packs/vita/images/" + PackID + ".png");
|
||||
break;
|
||||
case false:
|
||||
File.Delete(cache + "packs/normal/pcks/" + PackID + ".pck");
|
||||
File.Delete(cache + "packs/normal/images/" + PackID + ".png");
|
||||
break;
|
||||
}
|
||||
LocalTreeView.SelectedNode.Remove();
|
||||
switch (LActions.SaveLocalJSON(LocalCollections.CenterPacks, CategoryComboBoxLocal.Text, VitaCheckBox2.Checked))
|
||||
{
|
||||
case false:
|
||||
MessageBox.Show("Could not save JSON due to unknown error");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,15 +11,18 @@ using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Media.Imaging;
|
||||
using RichPresenceClient;
|
||||
using API.PCKCenter.model;
|
||||
using API.PCKCenter;
|
||||
|
||||
namespace PckStudio.Forms
|
||||
{
|
||||
public partial class pckCenter : MetroFramework.Forms.MetroForm
|
||||
{
|
||||
string[] mods;
|
||||
string hosturl = File.ReadAllText(appData + "\\settings.ini").Split(new[] { "\r\n", "\n" }, StringSplitOptions.None)[1] + "/studio/PCK/api/";
|
||||
string loadDirectory = File.ReadAllText(appData + "\\settings.ini").Split(new[] { "\r\n", "\n" }, StringSplitOptions.None)[1] + "/studio/PCK/api/pckCenterList.txt";
|
||||
string hosturl = "http://pckstudio.xyz/studio/PCK/api/";
|
||||
string loadDirectory = "http://pckstudio.xyz/studio/PCK/api/pckCenterList.txt";
|
||||
static string appData = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "/PCK Studio/";
|
||||
LocalActions LAct = new LocalActions();
|
||||
string cacheDir;
|
||||
|
||||
bool nobleLoaded = true;
|
||||
@@ -88,6 +91,9 @@ namespace PckStudio.Forms
|
||||
control.Dispose();
|
||||
}
|
||||
|
||||
PCKCenterJSON PJSON = new PCKCenterJSON();
|
||||
PJSON.Data = new Dictionary<string, EntryInfo>();
|
||||
int x = 0;
|
||||
foreach (string mod in mods)
|
||||
{
|
||||
try
|
||||
@@ -167,12 +173,22 @@ namespace PckStudio.Forms
|
||||
bool IsVita = (parseDesc[5] == "true" || parseDesc[5] == "True");
|
||||
string Packname = parseDesc[6];
|
||||
|
||||
EntryInfo EInfo = new EntryInfo();
|
||||
EInfo.Name = pckName;
|
||||
EInfo.Author = author;
|
||||
EInfo.Description = desc;
|
||||
PJSON.Data.Add((++x).ToString(), EInfo);
|
||||
File.Copy(cacheDir + mod + ".png", cacheDir + "images/" + ++x + ".png");
|
||||
|
||||
|
||||
PckPreview pckPreview = new PckPreview(pckName, author, desc, direct, ad, bmp, 0, mod, null, IsVita, Packname);
|
||||
pckLayout.Controls.Add(pckPreview);
|
||||
}
|
||||
}
|
||||
catch(Exception err) { Console.WriteLine(err.Message); }
|
||||
catch (Exception err) { Console.WriteLine(err.Message); }
|
||||
x++;
|
||||
}
|
||||
LAct.SaveLocalJSON(PJSON, loadDirectory.Replace(hosturl + "pckCenter", "").Replace(".txt", ""), isVita);
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
|
||||
@@ -136,6 +136,8 @@
|
||||
<Reference Include="WindowsFormsIntegration" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Classes\API\PCKCenter\model\PCKCenterJSON.cs" />
|
||||
<Compile Include="Classes\API\PCKCenter\SaveLocalJSON.cs" />
|
||||
<Compile Include="Classes\FileTypes\Bink.cs" />
|
||||
<Compile Include="Classes\FileTypes\COLFile.cs" />
|
||||
<Compile Include="Classes\FileTypes\CSM.cs" />
|
||||
|
||||
Reference in New Issue
Block a user