Skip to content

Commit

Permalink
Merge pull request #73 from Misaka-L/main
Browse files Browse the repository at this point in the history
bump dependencies, update ci, move docs into /docs
  • Loading branch information
Misaka-L authored Jun 22, 2023
2 parents 10182ef + 482c270 commit 62a5987
Show file tree
Hide file tree
Showing 9 changed files with 221 additions and 142 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/unity-packageu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,6 @@ jobs:
${{ env.zipFile }}
${{ env.unityPackage }}
Packages/${{ env.packageName }}/package.json
- name: Update Package Index
uses: vrcau/package-index/.github/workflows/release.yml
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@
using System.Text.RegularExpressions;
using UnityEditor;
using UnityEditor.UIElements;
using UnityEditor.VersionControl;
using UnityEngine;
using UnityEngine.UIElements;
using VRC.PackageManagement.Core.Types.Packages;
using YamlDotNet.Serialization.NodeTypeResolvers;

namespace VRC.PackageManagement.PackageMaker
{
Expand All @@ -23,6 +21,9 @@ public class PackageMakerWindow : EditorWindow
private TextField _packageIDField;
private Button _actionButton;
private EnumField _targetVRCPackageField;
private TextField _authorNameField;
private TextField _authorEmailField;
private TextField _authorUrlField;
private static string _projectDir;
private PackageMakerWindowData _windowData;

Expand All @@ -34,6 +35,9 @@ private void LoadDataFromSave()
}
_packageIDField.SetValueWithoutNotify(_windowData.packageID);
_targetVRCPackageField.SetValueWithoutNotify(_windowData.relatedPackage);
_authorEmailField.SetValueWithoutNotify(_windowData.authorEmail);
_authorNameField.SetValueWithoutNotify(_windowData.authorName);
_authorUrlField.SetValueWithoutNotify(_windowData.authorUrl);

RefreshActionButtonState();
}
Expand Down Expand Up @@ -101,7 +105,9 @@ private void RefreshActionButtonState()
{
_actionButton.SetEnabled(
StringIsValidAssetFolder(_windowData.targetAssetFolder) &&
!string.IsNullOrWhiteSpace(_windowData.packageID)
!string.IsNullOrWhiteSpace(_windowData.packageID) &&
!string.IsNullOrWhiteSpace(_windowData.authorName) &&
IsValidEmail(_windowData.authorEmail)
);
}

Expand All @@ -122,6 +128,7 @@ private void CreateGUI()
// Create Target Asset folder and register for drag and drop events
_rootView.Add(CreateTargetFolderElement());
_rootView.Add(CreatePackageIDElement());
_rootView.Add(CreateAuthorElement());
_rootView.Add(CreateTargetVRCPackageElement());
_rootView.Add(CreateActionButton());

Expand Down Expand Up @@ -206,6 +213,58 @@ private VisualElement CreatePackageIDElement()
return box;
}

private VisualElement CreateAuthorElement()
{
// Construct author fields
_authorNameField = new TextField("Author Name");
_authorEmailField = new TextField("Author Email");
_authorUrlField = new TextField("Author URL (optional)");

// Save name to window data and toggle the Action Button if its status changed
_authorNameField.RegisterValueChangedCallback((evt) =>
{
_windowData.authorName = evt.newValue;
RefreshActionButtonState();
});

// Save email to window data if valid and toggle the Action Button if its status changed
_authorEmailField.RegisterValueChangedCallback((evt) =>
{
// Only save email if it appears valid
if (IsValidEmail(evt.newValue))
{
_windowData.authorEmail = evt.newValue;
}
RefreshActionButtonState();
});

// Save url to window data, doesn't affect action button state
_authorUrlField.RegisterValueChangedCallback((evt) =>
{
_windowData.authorUrl = evt.newValue;
});

// Add new fields to layout
var box = new Box();
box.Add(_authorNameField);
box.Add(_authorEmailField);
box.Add(_authorUrlField);
return box;
}

private bool IsValidEmail(string evtNewValue)
{
try
{
var addr = new System.Net.Mail.MailAddress(evtNewValue);
return addr.Address == evtNewValue;
}
catch
{
return false;
}
}

private Regex packageIdRegex = new Regex("[^a-z0-9.]");
private void OnPackageIDChanged(ChangeEvent<string> evt)
{
Expand Down Expand Up @@ -335,13 +394,26 @@ private void DoMigration(string corePath, string targetDir)
}

string parentDir = new DirectoryInfo(targetDir)?.Parent.FullName;
Core.Utilities.CreateStarterPackage(_windowData.packageID, parentDir, packageType);
var packageDir = Core.Utilities.CreateStarterPackage(_windowData.packageID, parentDir, packageType);

// Modify manifest to add author
// Todo: add support for passing author into CreateStarterPackage
var manifest =
VRCPackageManifest.GetManifestAtPath(Path.Combine(packageDir, VRCPackageManifest.Filename)) as
VRCPackageManifest;
manifest.author = new Author()
{
email = _windowData.authorEmail,
name = _windowData.authorName,
url = _windowData.authorUrl
};
manifest.Save();

var allFiles = GetAllFiles(corePath).ToList();
MoveFilesToPackageDir(allFiles, corePath, targetDir);

// Clear target asset folder since it should no longer exist
_windowData.targetAssetFolder = "";

}

private static IEnumerable<string> GetAllFiles(string path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ public class PackageMakerWindowData : ScriptableObject
public static string defaultAssetPath = Path.Combine("Assets", "PackageMakerWindowData.asset");
public string targetAssetFolder;
public string packageID;

public string authorName;
public string authorEmail;
public string authorUrl;
public PackageMakerWindow.VRCPackageEnum relatedPackage;

public static PackageMakerWindowData GetOrCreate()
Expand Down
6 changes: 3 additions & 3 deletions Packages/com.vrchat.core.vpm-resolver/package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"name" : "com.vrchat.core.vpm-resolver",
"displayName" : "VRChat Package Resolver Tool",
"version" : "0.1.19",
"version" : "0.1.20",
"unity" : "2019.4",
"description" : "Tool to Download VPM Packages",
"vrchatVersion" : "2022.1.1",
"vrchatVersion" : "2022.2.2",
"author" : {
"name" : "VRChat",
"email" : "[email protected]",
"url" : "https://github.com/vrchat/packages"
},
"url" : "",
"dependencies" : {
"com.unity.nuget.newtonsoft-json" : "2.0.2"
"com.unity.nuget.newtonsoft-json" : "3.0.2"
}
}
Loading

0 comments on commit 62a5987

Please sign in to comment.