Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: add lib abstraction layer #138

Merged
merged 1 commit into from
Aug 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@

using System.Collections.Generic;
using Chocopoi.AvatarLib.Animations;
using Chocopoi.DressingTools.Lib.Logging;
using Chocopoi.DressingTools.Lib.Proxy;
using Chocopoi.DressingTools.Lib.Wearable;
using Chocopoi.DressingTools.Logging;
using Chocopoi.DressingTools.Proxy;
using Chocopoi.DressingTools.Wearable;
using Chocopoi.DressingTools.Wearable.Modules;
using UnityEngine;

Expand Down Expand Up @@ -69,21 +70,21 @@ private bool TryGetBlendshapeValue(GameObject obj, string blendshapeName, out fl
SkinnedMeshRenderer smr;
if ((smr = obj.GetComponent<SkinnedMeshRenderer>()) == null)
{
_report.LogWarnLocalized(LogLabel, MessageCode.IgnoredObjectHasNoSkinnedMeshRendererAttached, obj.name);
DTReportUtils.LogWarnLocalized(_report, LogLabel, MessageCode.IgnoredObjectHasNoSkinnedMeshRendererAttached, obj.name);
return false;
}

Mesh mesh;
if ((mesh = smr.sharedMesh) == null)
{
_report.LogWarnLocalized(LogLabel, MessageCode.IgnoredObjectHasNoMeshAttached, obj.name);
DTReportUtils.LogWarnLocalized(_report, LogLabel, MessageCode.IgnoredObjectHasNoMeshAttached, obj.name);
return false;
}

int blendshapeIndex;
if ((blendshapeIndex = mesh.GetBlendShapeIndex(blendshapeName)) == -1)
{
_report.LogWarnLocalized(LogLabel, MessageCode.IgnoredObjectHasNoSuchBlendshape, obj.name, blendshapeName);
DTReportUtils.LogWarnLocalized(_report, LogLabel, MessageCode.IgnoredObjectHasNoSuchBlendshape, obj.name, blendshapeName);
return false;
}

Expand All @@ -98,7 +99,7 @@ private void GenerateAvatarToggleAnimations(AnimationClip enableClip, AnimationC
var obj = _avatarObject.transform.Find(toggle.path);
if (obj == null)
{
_report.LogWarnLocalized(LogLabel, MessageCode.IgnoredAvatarToggleObjectNotFound, toggle.path);
DTReportUtils.LogWarnLocalized(_report, LogLabel, MessageCode.IgnoredAvatarToggleObjectNotFound, toggle.path);
}
else
{
Expand All @@ -118,13 +119,13 @@ private void GenerateAvatarBlendshapeAnimations(AnimationClip enableClip, Animat
var obj = _avatarObject.transform.Find(blendshape.path);
if (obj == null)
{
_report.LogWarnLocalized(LogLabel, MessageCode.IgnoredAvatarBlendshapeObjectNotFound, _avatarObject.name, blendshape.path);
DTReportUtils.LogWarnLocalized(_report, LogLabel, MessageCode.IgnoredAvatarBlendshapeObjectNotFound, _avatarObject.name, blendshape.path);
continue;
}

if (!TryGetBlendshapeValue(obj.gameObject, blendshape.blendshapeName, out var originalValue))
{
_report.LogWarnLocalized(LogLabel, MessageCode.IgnoredCouldNotObtainAvatarBlendshapeOriginalValue, _avatarObject.name, blendshape.path);
DTReportUtils.LogWarnLocalized(_report, LogLabel, MessageCode.IgnoredCouldNotObtainAvatarBlendshapeOriginalValue, _avatarObject.name, blendshape.path);
continue;
}

Expand All @@ -144,7 +145,7 @@ private void GenerateWearableToggleAnimations(AnimationClip enableClip, Animatio
var obj = _wearableObject.transform.Find(toggle.path);
if (obj == null)
{
_report.LogWarnLocalized(LogLabel, MessageCode.IgnoredWearableToggleObjectNotFound, toggle.path);
DTReportUtils.LogWarnLocalized(_report, LogLabel, MessageCode.IgnoredWearableToggleObjectNotFound, toggle.path);
}
else
{
Expand All @@ -164,12 +165,12 @@ private void GenerateWearableBlendshapeAnimations(AnimationClip enableClip, Anim
var obj = _wearableObject.transform.Find(blendshape.path);
if (obj == null)
{
_report.LogWarnLocalized(LogLabel, MessageCode.IgnoredAvatarBlendshapeObjectNotFound, _wearableObject.name, blendshape.path);
DTReportUtils.LogWarnLocalized(_report, LogLabel, MessageCode.IgnoredAvatarBlendshapeObjectNotFound, _wearableObject.name, blendshape.path);
}

if (!TryGetBlendshapeValue(obj.gameObject, blendshape.blendshapeName, out var originalValue))
{
_report.LogWarnLocalized(LogLabel, MessageCode.IgnoredCouldNotObtainWearableBlendshapeOriginalValue, _wearableObject.name, blendshape.path);
DTReportUtils.LogWarnLocalized(_report, LogLabel, MessageCode.IgnoredCouldNotObtainWearableBlendshapeOriginalValue, _wearableObject.name, blendshape.path);
continue;
}

Expand Down
11 changes: 6 additions & 5 deletions Packages/com.chocopoi.vrc.dressingtools/Editor/DTEditorUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
*/

using Chocopoi.DressingTools.Cabinet;
using Chocopoi.DressingTools.Wearable;
using Chocopoi.DressingTools.Lib.Cabinet;
using Chocopoi.DressingTools.Lib.Wearable;
using UnityEditor;
using UnityEngine;

Expand Down Expand Up @@ -71,8 +72,8 @@ public static DTCabinet GetAvatarCabinet(GameObject avatar, bool createIfNotExis
comp = avatar.AddComponent<DTCabinet>();

// TODO: read default config, scan for armature names?
comp.avatarGameObject = avatar;
comp.avatarArmatureName = "Armature";
comp.AvatarGameObject = avatar;
comp.AvatarArmatureName = "Armature";
}

return comp;
Expand Down Expand Up @@ -101,7 +102,7 @@ public static void AddCabinetWearable(DTCabinet cabinet, WearableConfig config,

public static void RemoveCabinetWearable(DTCabinet cabinet, DTCabinetWearable wearable)
{
var cabinetWearables = cabinet.avatarGameObject.GetComponentsInChildren<DTCabinetWearable>();
var cabinetWearables = cabinet.AvatarGameObject.GetComponentsInChildren<DTCabinetWearable>();
foreach (var cabinetWearable in cabinetWearables)
{
if (cabinetWearable == wearable)
Expand Down Expand Up @@ -137,7 +138,7 @@ public static void AddWearableTargetAvatarConfig(WearableConfig config, GameObje
}
else
{
config.targetAvatarConfig.armatureName = cabinet.avatarArmatureName;
config.targetAvatarConfig.armatureName = cabinet.AvatarArmatureName;
}

// can't do anything
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public override void OnInspectorGUI()
var cabinet = (DTCabinet)target;

EditorGUI.BeginDisabledGroup(true);
EditorGUILayout.ObjectField("Avatar", cabinet.avatarGameObject, typeof(GameObject), true);
EditorGUILayout.ObjectField("Avatar", cabinet.AvatarGameObject, typeof(GameObject), true);
EditorGUI.EndDisabledGroup();

EditorGUILayout.Separator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#if VRC_SDK_VRCSDK3
using Chocopoi.DressingTools.Cabinet;
using Chocopoi.DressingTools.Logging;
using Chocopoi.DressingTools.Lib.Logging;
using UnityEditor;
namespace Chocopoi.DressingTools.Integrations.VRChat
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Chocopoi.DressingTools.Lib.Logging;
using Chocopoi.DressingTools.Logging;
using Chocopoi.DressingTools.UI;
using UnityEditor;
Expand Down Expand Up @@ -79,7 +80,7 @@ public bool OnPreprocessAvatar(GameObject avatarGameObject)
}
catch (System.Exception ex)
{
report.LogExceptionLocalized(LogLabel, ex, "integrations.vrc.msgCode.error.exceptionProcessAvatar");
DTReportUtils.LogExceptionLocalized(report, LogLabel, ex, "integrations.vrc.msgCode.error.exceptionProcessAvatar");
}
finally
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
using Chocopoi.AvatarLib.Expressions;
using Chocopoi.DressingTools.Animations;
using Chocopoi.DressingTools.Cabinet;
using Chocopoi.DressingTools.Lib.Logging;
using Chocopoi.DressingTools.Lib.Wearable;
using Chocopoi.DressingTools.Logging;
using Chocopoi.DressingTools.Wearable;
using Chocopoi.DressingTools.Wearable.Modules;
using UnityEditor;
using UnityEditor.Animations;
Expand Down Expand Up @@ -63,7 +64,7 @@ public bool OnPreprocessAvatar()
EditorUtility.DisplayProgressBar("DressingTools", "Generating animations...", 0);

// get the avatar descriptor
var avatarDescriptor = _cabinet.avatarGameObject.GetComponent<VRCAvatarDescriptor>();
var avatarDescriptor = _cabinet.AvatarGameObject.GetComponent<VRCAvatarDescriptor>();

// obtain FX layer
var fxController = CopyAndReplaceLayerAnimator(avatarDescriptor, VRCAvatarDescriptor.AnimLayerType.FX);
Expand Down Expand Up @@ -112,7 +113,7 @@ public bool OnPreprocessAvatar()
}
catch (ParameterOverflowException ex)
{
_report.LogExceptionLocalized(LogLabel, ex, "integrations.vrc.msgCode.error.parameterOverFlow");
DTReportUtils.LogExceptionLocalized(_report, LogLabel, ex, "integrations.vrc.msgCode.error.parameterOverFlow");
return false;
}

Expand Down Expand Up @@ -157,7 +158,7 @@ public bool OnPreprocessAvatar()
continue;
}

var animationGenerator = new AnimationGenerator(_report, _cabinet.avatarGameObject, module, wearables[i].wearableGameObject, wearableDynamics);
var animationGenerator = new AnimationGenerator(_report, _cabinet.AvatarGameObject, module, wearables[i].wearableGameObject, wearableDynamics);

// TODO: write defaults settings
var wearAnimations = animationGenerator.GenerateWearAnimations(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
using System.Text.RegularExpressions;
using Chocopoi.DressingTools.Dresser;
using Chocopoi.DressingTools.Dresser.Default;
using Chocopoi.DressingTools.Lib.Logging;
using Chocopoi.DressingTools.Localization;
using Chocopoi.DressingTools.Logging;
using UnityEditor;
using UnityEditor.Animations;
using UnityEngine;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
using Chocopoi.DressingTools.Cabinet;
using Chocopoi.DressingTools.Dresser;
using Chocopoi.DressingTools.Dresser.Default;
using Chocopoi.DressingTools.Lib.Logging;
using Chocopoi.DressingTools.Lib.Wearable;
using Chocopoi.DressingTools.UI.View;
using Chocopoi.DressingTools.Wearable;
using Chocopoi.DressingTools.Wearable.Modules;
using Newtonsoft.Json;
using UnityEditor;
Expand Down Expand Up @@ -64,9 +65,9 @@ static void QuickAutoSetup(MenuCommand menuCommand)
}

var config = new WearableConfig();
DTEditorUtils.PrepareWearableConfig(config, cabinet.avatarGameObject, wearable);
DTEditorUtils.PrepareWearableConfig(config, cabinet.AvatarGameObject, wearable);

var armatureName = cabinet.avatarArmatureName;
var armatureName = cabinet.AvatarArmatureName;

// attempt to find wearable armature using avatar armature name
var armature = DTRuntimeUtils.GuessArmature(wearable, armatureName);
Expand All @@ -86,15 +87,15 @@ static void QuickAutoSetup(MenuCommand menuCommand)

var dresserSettings = new DefaultDresserSettings()
{
targetAvatar = cabinet.avatarGameObject,
targetAvatar = cabinet.AvatarGameObject,
targetWearable = wearable,
dynamicsOption = DefaultDresserDynamicsOption.RemoveDynamicsAndUseParentConstraint
};

var dresser = new DefaultDresser();
var report = dresser.Execute(dresserSettings, out _);

if (report.HasLogType(Logging.DTReportLogType.Error))
if (report.HasLogType(DTReportLogType.Error))
{
ReportWindow.ShowWindow(report);
EditorUtility.DisplayDialog("DressingTools", "Default dresser has errors processing this wearable automatically, please use the wizard instead.", "OK");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*/

using System.Collections.Generic;
using Chocopoi.DressingTools.Lib.Wearable;
using Chocopoi.DressingTools.UI.View;
using Chocopoi.DressingTools.Wearable;
using Chocopoi.DressingTools.Wearable.Modules;
using UnityEditor;
using UnityEngine;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*/

using Chocopoi.DressingTools.Cabinet;
using Chocopoi.DressingTools.Lib.Wearable;
using Chocopoi.DressingTools.UIBase.Views;
using Chocopoi.DressingTools.Wearable;
using Newtonsoft.Json;

namespace Chocopoi.DressingTools.UI.Presenters
Expand Down Expand Up @@ -75,8 +75,8 @@ private void OnCabinetSettingsChange()

var cabinet = cabinets[_view.SelectedCabinetIndex];

cabinet.avatarArmatureName = _view.CabinetAvatarArmatureName;
cabinet.avatarGameObject = _view.CabinetAvatarGameObject;
cabinet.AvatarArmatureName = _view.CabinetAvatarArmatureName;
cabinet.AvatarGameObject = _view.CabinetAvatarGameObject;
}

private void OnForceUpdateView()
Expand Down Expand Up @@ -118,7 +118,7 @@ private void UpdateCabinetSelectionDropdown(DTCabinet[] cabinets)
string[] cabinetOptions = new string[cabinets.Length];
for (var i = 0; i < cabinets.Length; i++)
{
cabinetOptions[i] = cabinets[i].avatarGameObject != null ? cabinets[i].avatarGameObject.name : string.Format("Cabinet {0} (No GameObject Attached)", i + 1);
cabinetOptions[i] = cabinets[i].AvatarGameObject != null ? cabinets[i].AvatarGameObject.name : string.Format("Cabinet {0} (No GameObject Attached)", i + 1);
}
_view.AvailableCabinetSelections = cabinetOptions;
}
Expand Down Expand Up @@ -148,8 +148,8 @@ private void UpdateView()
// update selected cabinet view
var cabinet = cabinets[_view.SelectedCabinetIndex];

_view.CabinetAvatarGameObject = cabinet.avatarGameObject;
_view.CabinetAvatarArmatureName = cabinet.avatarArmatureName;
_view.CabinetAvatarGameObject = cabinet.AvatarGameObject;
_view.CabinetAvatarArmatureName = cabinet.AvatarArmatureName;

var wearables = cabinet.GetWearables();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

using System.Collections.Generic;
using Chocopoi.AvatarLib.Animations;
using Chocopoi.DressingTools.Lib.Wearable;
using Chocopoi.DressingTools.UIBase.Views;
using Chocopoi.DressingTools.Wearable;
using Chocopoi.DressingTools.Wearable.Modules;
using UnityEngine;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
*/

using System.Collections.Generic;
using Chocopoi.DressingTools.Lib.UI;
using Chocopoi.DressingTools.Lib.Wearable;
using Chocopoi.DressingTools.UIBase.Views;
using Chocopoi.DressingTools.Wearable;
using Chocopoi.DressingTools.Wearable.Modules;
using UnityEngine;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
using Chocopoi.DressingTools.Cabinet;
using Chocopoi.DressingTools.Dresser;
using Chocopoi.DressingTools.Dresser.Default;
using Chocopoi.DressingTools.Logging;
using Chocopoi.DressingTools.Lib.Logging;
using Chocopoi.DressingTools.Lib.UI;
using Chocopoi.DressingTools.Lib.Wearable;
using Chocopoi.DressingTools.UIBase.Views;
using Chocopoi.DressingTools.Wearable;
using Chocopoi.DressingTools.Wearable.Modules;
using Newtonsoft.Json;
using UnityEditor;
Expand Down Expand Up @@ -188,8 +189,8 @@ private void UpdateDresserSettings()
if (_cabinet != null)
{
_view.IsAvatarAssociatedWithCabinet = true;
_view.AvatarArmatureName = _cabinet.avatarArmatureName;
_view.DresserSettings.avatarArmatureName = _cabinet.avatarArmatureName;
_view.AvatarArmatureName = _cabinet.AvatarArmatureName;
_view.DresserSettings.avatarArmatureName = _cabinet.AvatarArmatureName;
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
* You should have received a copy of the GNU General Public License along with DressingTools. If not, see <https://www.gnu.org/licenses/>.
*/

using Chocopoi.DressingTools.Lib.Wearable;
using Chocopoi.DressingTools.UIBase.Views;
using Chocopoi.DressingTools.Wearable;
using Chocopoi.DressingTools.Wearable.Modules;
using UnityEngine;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License along with DressingTools. If not, see <https://www.gnu.org/licenses/>.
*/

using Chocopoi.DressingTools.Lib.UI;
using Chocopoi.DressingTools.UIBase.Views;
using Chocopoi.DressingTools.Wearable.Modules;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Chocopoi.DressingTools.UI.Views.Modules;
using Chocopoi.DressingTools.Lib.UI;
using Chocopoi.DressingTools.Lib.Wearable;
using Chocopoi.DressingTools.Lib.Wearable.Modules;
using Chocopoi.DressingTools.UIBase.Views;
using Chocopoi.DressingTools.Wearable;
using Chocopoi.DressingTools.Wearable.Modules;
using UnityEditor;
using UnityEngine;

Expand Down Expand Up @@ -90,7 +90,7 @@ private void ApplyTargetAvatarConfigChanges()
}
else
{
_view.Config.targetAvatarConfig.armatureName = cabinet.avatarArmatureName;
_view.Config.targetAvatarConfig.armatureName = cabinet.AvatarArmatureName;
}

// can't do anything
Expand Down Expand Up @@ -177,7 +177,7 @@ private void OnAddModuleButtonClick()
UpdateModulesView();
}

private ModuleEditor CreateModuleEditor(IWearableModule module)
private ModuleEditor CreateModuleEditor(WearableModuleBase module)
{
// prepare cache if not yet
if (s_moduleEditorTypesCache == null)
Expand Down
Loading