Skip to content

Commit

Permalink
Improve publishing UI
Browse files Browse the repository at this point in the history
  • Loading branch information
BocuD committed Sep 5, 2022
1 parent 5b8370c commit 961998c
Show file tree
Hide file tree
Showing 2 changed files with 131 additions and 123 deletions.
252 changes: 129 additions & 123 deletions Packages/com.bocud.vrbuildhelper/BuildHelper/Editor/BuildHelperWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1990,154 +1990,177 @@ private void DrawPublishingOptions()
GUILayout.FlexibleSpace();
EditorGUILayout.LabelField(
$"<i>{(APIUser.IsLoggedIn ? "Currently logged in as " + APIUser.CurrentUser.displayName : "")}</i>",
styleRichTextLabel);
EditorGUILayout.EndHorizontal();
styleRichTextLabel, GUILayout.ExpandWidth(false));

bool publishBlocked = !CheckAccount(buildHelperData.CurrentBranch);

if (!CheckAccount(buildHelperData.CurrentBranch, false))
if (!publishBlocked)
{
EditorGUILayout.HelpBox("The currently logged in user doesn't have permission to publish to this blueprint ID.", MessageType.Error);
if (GUILayout.Button(" Switch ", GUILayout.ExpandWidth(false)))
{
VRCSettings.ActiveWindowPanel = 0;
GetWindow<VRCSdkControlPanel>();
}
}

EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField("Publish to VRChat");

bool lastBuildBlocked = !CheckLastBuiltBranch();
string lastBuildBlockedTooltip =
$"Your last build for the current platform couldn't be found, its hash doesn't match the last {CurrentPlatform()} build for this branch, or was built for a different blueprint ID.";
EditorGUILayout.EndHorizontal();

using (new EditorGUI.DisabledScope(lastBuildBlocked))
if (publishBlocked)
{
lastBuildButton.tooltip = lastBuildBlocked
? lastBuildBlockedTooltip
: "Equivalent to (Last build) Build & Publish in the VRChat SDK";
EditorGUILayout.HelpBox("The currently logged in user doesn't have permission to publish to this blueprint ID.", MessageType.Error);

if (GUILayout.Button(lastBuildButton, buttonStyle))
if (GUILayout.Button("Open VRChat SDK Control Panel to switch accounts"))
{
BuildHelperData.RunLastBuildChecks();

if (CheckLastBuiltBranch())
{
Branch targetBranch = buildHelperData.CurrentBranch;

bool canPublish = true;
if (!targetBranch.remoteExists && !targetBranch.HasVRCDataChanges() &&
BuildHelperEditorPrefs.UseAsyncPublish)
{
canPublish = EditorUtility.DisplayDialog("Build Helper",
$"You are about to publish a new world, but you haven't edited any world details. The async publisher doesn't enter playmode to let you edit world details, so your world will be uploaded as '{targetBranch.editedName}'. Do you want to continue?",
"Continue", "Cancel");
}

if (canPublish && CheckAccount(targetBranch))
{
if (BuildHelperEditorPrefs.UseAsyncPublish)
{
Branch b = buildHelperData.CurrentBranch;
BuildHelperBuilder.PublishWorldAsync(b.buildData.CurrentPlatformBuildData().buildPath,
"", b.ToWorldInfo(), info =>
{
Task verify =
buildHelperBehaviour.OnSuccesfulPublish(buildHelperData.CurrentBranch,
info.blueprintID,
DateTime.Now);
});
}
else BuildHelperBuilder.PublishLastBuild();
}
}
else
{
EditorUtility.DisplayDialog("BuildHelper", "Couldn't find the last build for this branch. Try building again.", "OK");
}
VRCSettings.ActiveWindowPanel = 0;
GetWindow<VRCSdkControlPanel>();
}
}

newBuildButton.tooltip = "Equivalent to Build & Publish in the VRChat SDK";

if (GUILayout.Button(newBuildButton, buttonStyle))
using (new EditorGUI.DisabledScope(publishBlocked))
{
Branch targetBranch = buildHelperData.CurrentBranch;
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField("Publish to VRChat");

bool canPublish = true;
if (!targetBranch.remoteExists && !targetBranch.HasVRCDataChanges() &&
BuildHelperEditorPrefs.UseAsyncPublish)
{
canPublish = EditorUtility.DisplayDialog("Build Helper",
$"You are about to publish a new world, but you haven't edited any world details. The async publisher doesn't enter playmode to let you edit world details, so your world will be uploaded as '{targetBranch.editedName}'. Do you want to continue?",
"Continue", "Cancel");
}
bool lastBuildBlocked = !CheckLastBuiltBranch();
string lastBuildBlockedTooltip =
$"Your last build for the current platform couldn't be found, its hash doesn't match the last {CurrentPlatform()} build for this branch, or was built for a different blueprint ID.";

if (canPublish && CheckAccount(targetBranch))
using (new EditorGUI.DisabledScope(lastBuildBlocked))
{
if (BuildHelperEditorPrefs.UseAsyncPublish)
lastBuildButton.tooltip = lastBuildBlocked
? lastBuildBlockedTooltip
: "Equivalent to (Last build) Build & Publish in the VRChat SDK";

if (GUILayout.Button(lastBuildButton, buttonStyle))
{
BuildHelperBuilder.PublishNewBuildAsync(buildHelperData.CurrentBranch.ToWorldInfo(), info =>
{
Task verify = buildHelperBehaviour.OnSuccesfulPublish(buildHelperData.CurrentBranch,
info.blueprintID, DateTime.Now);
});
}
else BuildHelperBuilder.PublishNewBuild();
}
BuildHelperData.RunLastBuildChecks();

return;
}
if (CheckLastBuiltBranch())
{
Branch targetBranch = buildHelperData.CurrentBranch;

EditorGUILayout.EndHorizontal();
bool canPublish = true;
if (!targetBranch.remoteExists && !targetBranch.HasVRCDataChanges() &&
BuildHelperEditorPrefs.UseAsyncPublish)
{
canPublish = EditorUtility.DisplayDialog("Build Helper",
$"You are about to publish a new world, but you haven't edited any world details. The async publisher doesn't enter playmode to let you edit world details, so your world will be uploaded as '{targetBranch.editedName}'. Do you want to continue?",
"Continue", "Cancel");
}

EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField("Autonomous Builder");
if (canPublish)
{
if (BuildHelperEditorPrefs.UseAsyncPublish)
{
Branch b = buildHelperData.CurrentBranch;
BuildHelperBuilder.PublishWorldAsync(
b.buildData.CurrentPlatformBuildData().buildPath,
"", b.ToWorldInfo(), info =>
{
Task verify =
buildHelperBehaviour.OnSuccesfulPublish(buildHelperData.CurrentBranch,
info.blueprintID,
DateTime.Now);
});
}
else BuildHelperBuilder.PublishLastBuild();
}
}
else
{
EditorUtility.DisplayDialog("BuildHelper",
"Couldn't find the last build for this branch. Try building again.", "OK");
}
}
}

using (new EditorGUI.DisabledScope(!BuildHelperEditorPrefs.UseAsyncPublish))
{
GUIContent autonomousBuilderButtonSingle = new GUIContent("Current platform",
BuildHelperEditorPrefs.UseAsyncPublish
? "Publish your world autonomously"
: "To use the autonomous builder, please enable Async Publishing in settings");
newBuildButton.tooltip = "Equivalent to Build & Publish in the VRChat SDK";

if (GUILayout.Button(currentPlatformPublish, buttonStyle))
if (GUILayout.Button(newBuildButton, buttonStyle))
{
Branch targetBranch = buildHelperData.CurrentBranch;

bool canPublish = true;
if (!targetBranch.remoteExists && !targetBranch.HasVRCDataChanges())
if (!targetBranch.remoteExists && !targetBranch.HasVRCDataChanges() &&
BuildHelperEditorPrefs.UseAsyncPublish)
{
canPublish = EditorUtility.DisplayDialog("Build Helper",
$"You are about to publish a new world using the autonomous builder, but you haven't edited any world details. The autonomous builder doesn't enter playmode to let you edit world details, so your world will be uploaded as '{targetBranch.editedName}'. Do you want to continue?",
$"You are about to publish a new world, but you haven't edited any world details. The async publisher doesn't enter playmode to let you edit world details, so your world will be uploaded as '{targetBranch.editedName}'. Do you want to continue?",
"Continue", "Cancel");
}

if (canPublish && CheckAccount(targetBranch))
if (canPublish)
{
InitAutonomousBuild(true);
if (BuildHelperEditorPrefs.UseAsyncPublish)
{
BuildHelperBuilder.PublishNewBuildAsync(buildHelperData.CurrentBranch.ToWorldInfo(), info =>
{
Task verify = buildHelperBehaviour.OnSuccesfulPublish(buildHelperData.CurrentBranch,
info.blueprintID, DateTime.Now);
});
}
else BuildHelperBuilder.PublishNewBuild();
}

return;
}

GUIContent autonomousBuilderButton = new GUIContent("All platforms",
BuildHelperEditorPrefs.UseAsyncPublish
? "Publish your world for both platforms simultaneously"
: "To use the autonomous builder, please enable Async Publishing in settings");
EditorGUILayout.EndHorizontal();

EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField("Autonomous Builder");

if (GUILayout.Button(crossPlatformPublish, buttonStyle))
using (new EditorGUI.DisabledScope(!BuildHelperEditorPrefs.UseAsyncPublish))
{
Branch targetBranch = buildHelperData.CurrentBranch;
GUIContent autonomousBuilderButtonSingle = new GUIContent("Current platform",
BuildHelperEditorPrefs.UseAsyncPublish
? "Publish your world autonomously"
: "To use the autonomous builder, please enable Async Publishing in settings");

bool canPublish = true;
if (!targetBranch.remoteExists && !targetBranch.HasVRCDataChanges())
if (GUILayout.Button(currentPlatformPublish, buttonStyle))
{
canPublish = EditorUtility.DisplayDialog("Build Helper",
$"You are about to publish a new world using the autonomous builder, but you haven't edited any world details. The autonomous builder doesn't enter playmode to let you edit world details, so your world will be uploaded as '{targetBranch.editedName}'. Do you want to continue?",
"Continue", "Cancel");
Branch targetBranch = buildHelperData.CurrentBranch;

bool canPublish = true;
if (!targetBranch.remoteExists && !targetBranch.HasVRCDataChanges())
{
canPublish = EditorUtility.DisplayDialog("Build Helper",
$"You are about to publish a new world using the autonomous builder, but you haven't edited any world details. The autonomous builder doesn't enter playmode to let you edit world details, so your world will be uploaded as '{targetBranch.editedName}'. Do you want to continue?",
"Continue", "Cancel");
}

if (canPublish)
{
InitAutonomousBuild(true);
}
}

if (canPublish && CheckAccount(targetBranch))
GUIContent autonomousBuilderButton = new GUIContent("All platforms",
BuildHelperEditorPrefs.UseAsyncPublish
? "Publish your world for both platforms simultaneously"
: "To use the autonomous builder, please enable Async Publishing in settings");

if (GUILayout.Button(crossPlatformPublish, buttonStyle))
{
InitAutonomousBuild();
Branch targetBranch = buildHelperData.CurrentBranch;

bool canPublish = true;
if (!targetBranch.remoteExists && !targetBranch.HasVRCDataChanges())
{
canPublish = EditorUtility.DisplayDialog("Build Helper",
$"You are about to publish a new world using the autonomous builder, but you haven't edited any world details. The autonomous builder doesn't enter playmode to let you edit world details, so your world will be uploaded as '{targetBranch.editedName}'. Do you want to continue?",
"Continue", "Cancel");
}

if (canPublish)
{
InitAutonomousBuild();
}
}
}
}

EditorGUILayout.EndHorizontal();
EditorGUILayout.EndHorizontal();
}

EditorGUILayout.EndVertical();
}
Expand All @@ -2149,7 +2172,7 @@ private bool CheckLastBuiltBranch()
currentBranch.buildData.CurrentPlatformBuildData().blueprintID;
}

private static bool CheckAccount(Branch target, bool showDialog = true)
private static bool CheckAccount(Branch target)
{
if (target.blueprintID == "")
{
Expand All @@ -2160,29 +2183,12 @@ private static bool CheckAccount(Branch target, bool showDialog = true)
{
if (APIUser.CurrentUser.id != ((ApiWorld)model).authorId)
{
if (showDialog && EditorUtility.DisplayDialog("Build Helper",
"The world author for the selected branch doesn't match the currently logged in user. Publishing will result in an error. Do you still want to continue?",
"Yes", "No"))
{
return true;
}

return false;
}

return true;
}

if (showDialog)
{
if (EditorUtility.DisplayDialog("Build Helper",
"Couldn't verify the world author for the selected branch. Do you want to try publishing anyways?",
"Yes", "No"))
{
return true;
}
}


return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public static void CleanupCamera()
{
CameraData cam = UnityEngine.Object.FindObjectOfType<CameraData>();

if (cam == null) return;

if (cam.transform.parent == null)
{
BuildHelperData buildHelperData = BuildHelperData.GetDataBehaviour();
Expand Down

0 comments on commit 961998c

Please sign in to comment.