Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Killers0992 committed Mar 29, 2022
1 parent 985ef2e commit f85394d
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 58 deletions.
4 changes: 4 additions & 0 deletions AwtterSDK.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
<Reference Include="UnityEngine.IMGUIModule">
<HintPath>..\..\..\..\..\Program Files\Unity\Hub\Editor\2019.4.30f1\Editor\Data\Managed\UnityEngine\UnityEngine.IMGUIModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.JSONSerializeModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\Managed\UnityEngine\UnityEngine.JSONSerializeModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.TextRenderingModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\Program Files\Unity\Hub\Editor\2019.4.30f1\Editor\Data\Managed\UnityEngine\UnityEngine.TextRenderingModule.dll</HintPath>
Expand Down
11 changes: 6 additions & 5 deletions Editor/AssetsTreeView/AssetsView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,23 +114,24 @@ void CellGUI(Rect cellRect, TreeViewItem<AssetElement> item, MyColumns column, r
args.rowRect = cellRect;
var defColor = GUI.color;
Rect statusRect = cellRect;
cellRect.x += 18f;
cellRect.x += 25f;

switch (item.data.Status)
{
case PackageStatus.None:
case PackageStatus.NotInstalled:
statusRect.width = 18f;
statusRect.width = 25f;
GUI.color = Color.red;
EditorGUI.LabelField(statusRect, "❌");
GUI.color = defColor;
EditorGUI.LabelField(cellRect, "Not Installed");
EditorGUI.LabelField(cellRect, " Not Installed");
break;
case PackageStatus.Installed:
statusRect.width = 18f;
statusRect.width = 25f;
GUI.color = Color.green;
EditorGUI.LabelField(statusRect, "✔️");
GUI.color = defColor;
EditorGUI.LabelField(cellRect, "Installed");
EditorGUI.LabelField(cellRect, " Installed");
break;
}
}
Expand Down
94 changes: 68 additions & 26 deletions Editor/AwtterSdkInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAsse

public class AwtterSdkInstaller : EditorWindow
{
public static bool LoggedIn;
public static bool BaseInstalled;
public static int BaseType;

Expand All @@ -51,7 +52,8 @@ public class AwtterSdkInstaller : EditorWindow
{ "basemodel", new BaseInstallation() },
};

DownloadableContent _downloadableContent = new DownloadableContent()
DownloadableContent _downloadableContent = null;
DownloadableContent _downloadableContentTemplate = new DownloadableContent()
{
Models = new List<BaseModel>()
{
Expand Down Expand Up @@ -88,7 +90,7 @@ public class AwtterSdkInstaller : EditorWindow
{
Name = "Test DLC",
DownloadLink = "<DLC AA>",
Dependencies = new string [] { "vrcsdk", "poiyomi", "awdder" }
Dependencies = new string [] { "vrcsdk", "poiyomi", "awdeer" }
}
}
}
Expand All @@ -115,8 +117,20 @@ public class AwtterSdkInstaller : EditorWindow
}
};


[MenuItem("Awtter SDK/Open Installer")]
static void Init()
{
//_window = (AwtterSdkInstaller)EditorWindow.GetWindowWithRect(typeof(AwtterSdkInstaller), new Rect(0, 0, 525, 248), false, "Awtter SDK | Installer");
_window = (AwtterSdkInstaller)EditorWindow.GetWindow(typeof(AwtterSdkInstaller), false, "Awtter SDK | Installer");
_window.Show();
CheckPackages = true;
}

internal List<AssetElement> CreateView()
{
if (_downloadableContent == null) return new List<AssetElement>();

List<AssetElement> elements = new List<AssetElement>()
{
new AssetElement(string.Empty, string.Empty, -1, 0),
Expand Down Expand Up @@ -166,15 +180,6 @@ public static Texture GetTextureOrDownload(string url)
return CachedTextures[url] ?? DefaultTexture;
}

[MenuItem("Awtter SDK/Open Installer")]
static void Init()
{
//_window = (AwtterSdkInstaller)EditorWindow.GetWindowWithRect(typeof(AwtterSdkInstaller), new Rect(0, 0, 525, 248), false, "Awtter SDK | Installer");
_window = (AwtterSdkInstaller)EditorWindow.GetWindow(typeof(AwtterSdkInstaller), false, "Awtter SDK | Installer");
_window.Show();
CheckPackages = true;
}

void InitIfNeeded()
{
if (!m_Initialized)
Expand Down Expand Up @@ -229,8 +234,42 @@ void CheckInstalledPackages()
CheckPackages = false;
}

string username, password;

void Login()
{
if (!File.Exists("Assets/downloadableContent.json"))
File.WriteAllText("Assets/downloadableContent.json", JsonUtility.ToJson(_downloadableContentTemplate, true));

_downloadableContent = JsonUtility.FromJson<DownloadableContent>(File.ReadAllText("Assets/downloadableContent.json"));
LoggedIn = true;
}

void Logout()
{
LoggedIn = false;
}

void OnGUI()
{
if (!LoggedIn)
{
GUILayout.Space(150);
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUILayout.BeginVertical("Account", "window", GUILayout.Height(120), GUILayout.Width(300));
GUI.enabled = false;
username = EditorGUILayout.TextField("Email", username);
password = EditorGUILayout.PasswordField("Password", password);
GUI.enabled = true;
if (GUILayout.Button("Login")) Login();
if (GUILayout.Button("Register")) Application.OpenURL("https://shadedoes3d.com");
GUILayout.EndVertical();
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
return;
}

if (TexturesToDownload.Count != 0)
{
var link = TexturesToDownload.Dequeue();
Expand All @@ -249,13 +288,15 @@ void OnGUI()
TopToolBar(toolbarRect);
m_TreeView.OnGUI(packagesTreeViewRect);
BottomToolBar(bottomToolbarRect);

}


void TopToolBar(Rect rect)
{
GUILayout.BeginArea(rect);
EditorGUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
if (GUILayout.Button("Logout")) Logout();
EditorGUILayout.EndHorizontal();
CreateBox("Installed assets");
GUILayout.EndArea();
}
Expand All @@ -279,23 +320,24 @@ void BottomToolBar(Rect rect)
{
CreateBox("Installation options");
BaseType = EditorGUILayout.Popup("Model base", BaseType, _downloadableContent.Models.Select(x => x.Name).ToArray());

EditorGUILayout.BeginHorizontal();

EditorGUILayout.BeginVertical();
CreateBox("Base");
EditorGUILayout.LabelField($"Name {_downloadableContent.Models[BaseType].Name}");
GUILayout.Label($"Name {_downloadableContent.Models[BaseType].Name}");
EditorGUILayout.EndVertical();

EditorGUILayout.BeginVertical();
CreateBox("Avaliable DLCS");
for(int x = 0; x < _downloadableContent.Models[BaseType].AvaliableDLC.Count; x++)
for (int x = 0; x < _downloadableContent.Models[BaseType].AvaliableDLC.Count; x++)
{
GUILayout.BeginHorizontal();
EditorGUILayout.BeginHorizontal();
GUILayout.Label(_downloadableContent.Models[BaseType].AvaliableDLC[x].Name);
GUILayout.FlexibleSpace();
_downloadableContent.Models[BaseType].AvaliableDLC[x].Install = EditorGUILayout.Toggle(_downloadableContent.Models[BaseType].AvaliableDLC[x].Install);
GUILayout.EndHorizontal();
EditorGUILayout.EndHorizontal();
}
EditorGUILayout.EndVertical();
GUILayout.FlexibleSpace();
EditorGUILayout.EndHorizontal();
}

Expand Down Expand Up @@ -324,12 +366,12 @@ void BottomToolBar(Rect rect)
GUILayout.EndArea();
}

void CreateBox(string text)
void CreateBox(string text, bool flexible = true)
{
EditorGUILayout.BeginHorizontal("box");
GUILayout.FlexibleSpace();
EditorGUILayout.LabelField(text, EditorStyles.boldLabel);
GUILayout.FlexibleSpace();
if (flexible) GUILayout.FlexibleSpace();
GUILayout.Label(text, EditorStyles.boldLabel);
if (flexible) GUILayout.FlexibleSpace();
EditorGUILayout.EndHorizontal();
}

Expand Down Expand Up @@ -362,17 +404,17 @@ void DownloadFile(string url, string progressTitle, string progressInfo)

Rect toolbarRect
{
get { return new Rect(5f, 0f, position.width - 5f, 20f); }
get { return new Rect(0f, 0f, position.width, 25f); }
}

Rect packagesTreeViewRect
{
get { return new Rect(5f, 30, position.width - 5f, 140f); }
get { return new Rect(0f, 30f, position.width, 140f); }
}

Rect bottomToolbarRect
{
get { return new Rect(5f, 175, position.width - 5f, position.height - 160f); }
get { return new Rect(0f, 175f, position.width, position.height - 160f); }
}
}

Expand Down
21 changes: 12 additions & 9 deletions Editor/Models/BaseModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@

namespace AwtterSDK.Editor.Models
{
[Serializable]
internal class BaseModel
{
public int ViewID { get; set; }
public bool Install { get; set; }
public string Name { get; set; }
public string ShortName { get; set; }
public string Version { get; set; }
public string IconLink { get; set; }
public string DownloadLink { get; set; }
public string[] Dependencies { get; set; } = new string[0];
public List<DLC> AvaliableDLC { get; set; } = new List<DLC>();
[NonSerialized]
public int ViewID;
[NonSerialized]
public bool Install;
public string Name;
public string ShortName;
public string Version;
public string IconLink;
public string DownloadLink;
public string[] Dependencies = new string[0];
public List<DLC> AvaliableDLC = new List<DLC>();
}
}
17 changes: 10 additions & 7 deletions Editor/Models/DLC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@

namespace AwtterSDK.Editor.Models
{
[Serializable]
internal class DLC
{
public int ViewID { get; set; }
public bool Install { get; set; }
public string Name { get; set; }
public string Version { get; set; }
public string IconLink { get; set; }
public string DownloadLink { get; set; }
public string[] Dependencies { get; set; } = new string[0];
[NonSerialized]
public int ViewID;
[NonSerialized]
public bool Install;
public string Name;
public string Version;
public string IconLink;
public string DownloadLink;
public string[] Dependencies = new string[0];
}
}
6 changes: 4 additions & 2 deletions Editor/Models/DownloadableContent.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using AwtterSDK.Editor.Enums;
using System;
using System.Collections.Generic;

namespace AwtterSDK.Editor.Models
{
[Serializable]
internal class DownloadableContent
{
public List<BaseModel> Models { get; set; } = new List<BaseModel>();
public List<Package> Packages { get; set; } = new List<Package>();
public List<BaseModel> Models = new List<BaseModel>();
public List<Package> Packages = new List<Package>();
}
}
23 changes: 14 additions & 9 deletions Editor/Models/Package.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
namespace AwtterSDK.Editor.Models
using System;

namespace AwtterSDK.Editor.Models
{
[Serializable]
public class Package
{
public int ViewID { get; set; }
public bool Install { get; set; }
public string Name { get; set; }
public string ShortName { get; set; }
public string IconLink { get; set; }
public string Version { get; set; }
public bool AutoDetect { get; set; } = true;
public string DownloadLink { get; set; }
[NonSerialized]
public int ViewID;
[NonSerialized]
public bool Install;
public string Name;
public string ShortName;
public string IconLink;
public string Version;
public bool AutoDetect = true;
public string DownloadLink;
}
}

0 comments on commit f85394d

Please sign in to comment.