Skip to content

Commit

Permalink
feat: add MA/NDMF support to improve menu items compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
poi-vrc committed Mar 13, 2024
1 parent e99af13 commit e513d35
Show file tree
Hide file tree
Showing 43 changed files with 964 additions and 217 deletions.
41 changes: 41 additions & 0 deletions .github/unity-project/Packages/manifest.2022.3.6f1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"dependencies": {
"com.unity.ide.rider": "3.0.26",
"com.unity.ide.visualstudio": "2.0.22",
"com.unity.test-framework": "1.1.29",
"com.unity.textmeshpro": "2.1.6",
"com.unity.timeline": "1.2.18",
"com.unity.ugui": "1.0.0",
"com.unity.modules.ai": "1.0.0",
"com.unity.modules.androidjni": "1.0.0",
"com.unity.modules.animation": "1.0.0",
"com.unity.modules.assetbundle": "1.0.0",
"com.unity.modules.audio": "1.0.0",
"com.unity.modules.cloth": "1.0.0",
"com.unity.modules.director": "1.0.0",
"com.unity.modules.imageconversion": "1.0.0",
"com.unity.modules.imgui": "1.0.0",
"com.unity.modules.jsonserialize": "1.0.0",
"com.unity.modules.particlesystem": "1.0.0",
"com.unity.modules.physics": "1.0.0",
"com.unity.modules.physics2d": "1.0.0",
"com.unity.modules.screencapture": "1.0.0",
"com.unity.modules.terrain": "1.0.0",
"com.unity.modules.terrainphysics": "1.0.0",
"com.unity.modules.tilemap": "1.0.0",
"com.unity.modules.ui": "1.0.0",
"com.unity.modules.uielements": "1.0.0",
"com.unity.modules.umbra": "1.0.0",
"com.unity.modules.unityanalytics": "1.0.0",
"com.unity.modules.unitywebrequest": "1.0.0",
"com.unity.modules.unitywebrequestassetbundle": "1.0.0",
"com.unity.modules.unitywebrequestaudio": "1.0.0",
"com.unity.modules.unitywebrequesttexture": "1.0.0",
"com.unity.modules.unitywebrequestwww": "1.0.0",
"com.unity.modules.vehicles": "1.0.0",
"com.unity.modules.video": "1.0.0",
"com.unity.modules.vr": "1.0.0",
"com.unity.modules.wind": "1.0.0",
"com.unity.modules.xr": "1.0.0"
}
}
41 changes: 41 additions & 0 deletions .github/unity-project/Packages/manifest.2023.2.2f1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"dependencies": {
"com.unity.ide.rider": "3.0.26",
"com.unity.ide.visualstudio": "2.0.22",
"com.unity.test-framework": "1.1.29",
"com.unity.textmeshpro": "2.1.6",
"com.unity.timeline": "1.2.18",
"com.unity.ugui": "1.0.0",
"com.unity.modules.ai": "1.0.0",
"com.unity.modules.androidjni": "1.0.0",
"com.unity.modules.animation": "1.0.0",
"com.unity.modules.assetbundle": "1.0.0",
"com.unity.modules.audio": "1.0.0",
"com.unity.modules.cloth": "1.0.0",
"com.unity.modules.director": "1.0.0",
"com.unity.modules.imageconversion": "1.0.0",
"com.unity.modules.imgui": "1.0.0",
"com.unity.modules.jsonserialize": "1.0.0",
"com.unity.modules.particlesystem": "1.0.0",
"com.unity.modules.physics": "1.0.0",
"com.unity.modules.physics2d": "1.0.0",
"com.unity.modules.screencapture": "1.0.0",
"com.unity.modules.terrain": "1.0.0",
"com.unity.modules.terrainphysics": "1.0.0",
"com.unity.modules.tilemap": "1.0.0",
"com.unity.modules.ui": "1.0.0",
"com.unity.modules.uielements": "1.0.0",
"com.unity.modules.umbra": "1.0.0",
"com.unity.modules.unityanalytics": "1.0.0",
"com.unity.modules.unitywebrequest": "1.0.0",
"com.unity.modules.unitywebrequestassetbundle": "1.0.0",
"com.unity.modules.unitywebrequestaudio": "1.0.0",
"com.unity.modules.unitywebrequesttexture": "1.0.0",
"com.unity.modules.unitywebrequestwww": "1.0.0",
"com.unity.modules.vehicles": "1.0.0",
"com.unity.modules.video": "1.0.0",
"com.unity.modules.vr": "1.0.0",
"com.unity.modules.wind": "1.0.0",
"com.unity.modules.xr": "1.0.0"
}
}
10 changes: 5 additions & 5 deletions .github/unity-project/Packages/vpm-manifest.2022.3.6f1.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
{
"dependencies": {
"com.vrchat.avatars": {
"version": "3.5.0"
"version": "3.5.1"
},
"com.vrchat.core.vpm-resolver": {
"version": "0.1.27"
"version": "0.1.28"
}
},
"locked": {
"com.vrchat.avatars": {
"version": "3.5.0",
"version": "3.5.1",
"dependencies": {
"com.vrchat.base": "3.5.0"
"com.vrchat.base": "3.5.1"
}
},
"com.vrchat.base": {
"version": "3.5.0",
"version": "3.5.1",
"dependencies": {}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
m_EditorVersion: 2022.3.6f1
m_EditorVersionWithRevision: 2022.3.6f1 (b9e6e7e9fa2d)
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
m_EditorVersion: 2022.3.6f1
m_EditorVersionWithRevision: 2022.3.6f1 (b9e6e7e9fa2d)
31 changes: 26 additions & 5 deletions .github/workflows/unity-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,36 @@ name: Unity Tests

on:
push:
branches: master
paths:
- "**.cs"
- ".github/unity-project/**/*"
- ".github/workflows/unity-tests.yml"
pull_request:
paths:
- "**.cs"
- ".github/unity-project/**/*"
- ".github/workflows/unity-tests.yml"

jobs:
build:
name: Build and Test (${{ matrix.unity-version }}${{ matrix.import-vrcsdk && ', VRC' || '' }}${{ matrix.import-dynbone && ', DynBone' || '' }}${{ matrix.import-univrm && ', VRM' || '' }})
name: Build and Test (${{ matrix.unity-version }}${{ matrix.import-vrcsdk && ', VRC' || '' }}${{ matrix.import-dynbone && ', DynBone' || '' }}${{ matrix.import-univrm && ', VRM' || '' }}${{ matrix.import-ma && ', MA' || '' }})
runs-on: ubuntu-latest
strategy:
fail-fast: true
max-parallel: 6
matrix:
unity-version: ['2019.4.31f1', '2022.3.6f1', '2023.2.2f1']
import-vrcsdk: [false, true]
import-ma: [false, true]
# import-dynbone: [false, true]
# import-univrm: [false, true]
import-dynbone: [false]
import-univrm: [false]
exclude:
# - unity-version: "2019.4.31f1"
# import-univrm: true
- import-vrcsdk: false
import-ma: true
- unity-version: "2023.2.2f1"
import-vrcsdk: true
steps:
Expand All @@ -50,11 +58,17 @@ jobs:
- uses: actions/cache@v3
with:
path: Library
key: Library-${{ matrix.unity-version }}-${{ matrix.import-vrcsdk }}-${{ matrix.import-dynbone }}-${{ matrix.import-univrm }}-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }}
key: Library-${{ matrix.unity-version }}-${{ matrix.import-vrcsdk }}-${{ matrix.import-dynbone }}-${{ matrix.import-univrm }}-${{ matrix.import-ma }}-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }}
restore-keys: |
Library-${{ matrix.unity-version }}-${{ matrix.import-vrcsdk }}-${{ matrix.import-dynbone }}-${{ matrix.import-univrm }}-
Library-${{ matrix.unity-version }}-${{ matrix.import-vrcsdk }}-${{ matrix.import-dynbone }}-${{ matrix.import-univrm }}-${{ matrix.import-ma }}-
- name: Use UniVRM manifest
- name: Prepare base UPM manifest
run: mv Packages/manifest.${{ matrix.unity-version }}.json Packages/manifest.json

- name: Prepare ProjectVersion
run: mv ProjectSettings/ProjectVersion.${{ matrix.unity-version }}.txt ProjectSettings/ProjectVersion.txt

- name: Prepare UniVRM manifest
if: matrix.import-univrm
run: mv Packages/manifest-vrm.json Packages/manifest.json

Expand All @@ -63,8 +77,15 @@ jobs:
run: |
mv Packages/vpm-manifest.${{ matrix.unity-version }}.json Packages/vpm-manifest.json
dotnet tool install --global vrchat.vpm.cli
vpm add repo https://vpm.chocopoi.com/index.json
vpm resolve project
- name: Import ModularAvatar
if: matrix.import-ma
run: |
vpm add repo https://vpm.nadena.dev/vpm.json
vpm add package [email protected]
# DynamicsBones stub
- name: Import DynamicBones stub
if: matrix.import-dynbone
Expand Down
2 changes: 2 additions & 0 deletions Editor/Context.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using System;
using System.Collections.Generic;
using Chocopoi.DressingFramework.Animations;
using Chocopoi.DressingFramework.Extensibility.Sequencing;
using Chocopoi.DressingFramework.Logging;
using UnityEngine;
using Object = UnityEngine.Object;
Expand All @@ -26,6 +27,7 @@ public abstract class Context : IContext
{
public GameObject AvatarGameObject { get; private set; }

public abstract BuildRuntime CurrentRuntime { get; }
public abstract object RuntimeContext { get; }
internal abstract Report Report { get; }
public abstract Object AssetContainer { get; }
Expand Down
2 changes: 1 addition & 1 deletion Editor/Detail/DK/AvatarBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private void DispatchAnimationStore()
private bool RunPassesAtStage(BuildStage stage)
{
// Debug.Log($"[DK] =========== {stage} Start ===========");
var passes = _plugMgr.GetSortedBuildPassesAtStage(stage);
var passes = _plugMgr.GetSortedBuildPassesAtStage(BuildRuntime.DK, stage);

if (passes == null)
{
Expand Down
68 changes: 48 additions & 20 deletions Editor/Detail/DK/DKMAMenuStore.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*
* Copyright (c) 2024 chocopoi
*
* This file is part of DressingTools.
* This file is part of DressingFramework.
*
* DressingTools is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
* DressingFramework is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* DressingTools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
* DressingFramework is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with DressingTools. If not, see <https://www.gnu.org/licenses/>.
* You should have received a copy of the GNU General Public License along with DressingFramework. If not, see <https://www.gnu.org/licenses/>.
*/

#if DK_MA && DK_VRCSDK3A
Expand All @@ -30,13 +30,13 @@ namespace Chocopoi.DressingFramework.Detail.DK
internal class DKMAMenuStore : MenuStore
{
private readonly Context _ctx;
private readonly Dictionary<string, List<MenuItem>> _buffer;
private readonly Dictionary<string, MenuGroup> _buffer;
private readonly HashSet<VRCExpressionsMenu> _clonedVrcMenus;

public DKMAMenuStore(Context ctx)
{
_ctx = ctx;
_buffer = new Dictionary<string, List<MenuItem>>();
_buffer = new Dictionary<string, MenuGroup>();
_clonedVrcMenus = new HashSet<VRCExpressionsMenu>();
}

Expand All @@ -50,17 +50,17 @@ public override void Append(MenuItem menuItem, string path = null)

if (!_buffer.TryGetValue(path, out var menuItems))
{
menuItems = _buffer[path] = new List<MenuItem>();
menuItems = _buffer[path] = new MenuGroup();
}
menuItems.Add(menuItem);
}

private static VRCExpressionsMenu.Control MakeSubMenuControl(string name, VRCExpressionsMenu subMenu)
private static VRCExpressionsMenu.Control MakeSubMenuControl(string name, Texture2D icon, VRCExpressionsMenu subMenu)
{
return new VRCExpressionsMenu.Control()
{
name = name,
icon = null,
icon = icon,
type = VRCExpressionsMenu.Control.ControlType.SubMenu,
parameter = new VRCExpressionsMenu.Control.Parameter() { name = "" },
style = VRCExpressionsMenu.Control.Style.Style1,
Expand All @@ -76,7 +76,7 @@ private VRCExpressionsMenu MakeDownwardsMenuGroups(string[] paths, int index)
_ctx.CreateUniqueAsset(menu, string.Join("_", paths, 0, index));
if (index < paths.Length)
{
var newMenuItem = MakeSubMenuControl(paths[index], MakeDownwardsMenuGroups(paths, index + 1));
var newMenuItem = MakeSubMenuControl(paths[index], null, MakeDownwardsMenuGroups(paths, index + 1));
menu.controls.Add(newMenuItem);
}
return menu;
Expand Down Expand Up @@ -120,13 +120,48 @@ private VRCExpressionsMenu FindInstallTarget(VRCExpressionsMenu parent, string[]
}

Check warning on line 120 in Editor/Detail/DK/DKMAMenuStore.cs

View check run for this annotation

Codecov / codecov/patch

Editor/Detail/DK/DKMAMenuStore.cs#L120

Added line #L120 was not covered by tests

// if not found, we create empty menu groups recursively downwards
var newMenuItem = MakeSubMenuControl(paths[index], MakeDownwardsMenuGroups(paths, index + 1));
var newMenuItem = MakeSubMenuControl(paths[index], null, MakeDownwardsMenuGroups(paths, index + 1));
parent.controls.Add(newMenuItem);

// find again
return FindInstallTarget(parent, paths, index);
}

private static void DKToMAMenuItem(GameObject parent, MenuItem menuItem)
{
var maItemObj = new GameObject(menuItem.Name);
maItemObj.transform.SetParent(parent.transform);

var maItem = maItemObj.AddComponent<ModularAvatarMenuItem>();

if (menuItem is SubMenuItem subMenuItem)
{
maItem.Control = MakeSubMenuControl(menuItem.Name, menuItem.Icon, null);
maItem.MenuSource = SubmenuSource.Children;
if (subMenuItem.SubMenu != null)
{
DKGroupToMAItems(maItemObj, subMenuItem.SubMenu);
}
}

Check warning on line 145 in Editor/Detail/DK/DKMAMenuStore.cs

View check run for this annotation

Codecov / codecov/patch

Editor/Detail/DK/DKMAMenuStore.cs#L138-L145

Added lines #L138 - L145 were not covered by tests
else if (menuItem is VRCSubMenuItem vrcSubMenuItem)
{
maItem.Control = MakeSubMenuControl(menuItem.Name, menuItem.Icon, vrcSubMenuItem.SubMenu);
maItem.MenuSource = SubmenuSource.MenuAsset;
}

Check warning on line 150 in Editor/Detail/DK/DKMAMenuStore.cs

View check run for this annotation

Codecov / codecov/patch

Editor/Detail/DK/DKMAMenuStore.cs#L147-L150

Added lines #L147 - L150 were not covered by tests
else
{
maItem.Control = VRCMenuUtils.MenuItemToControl(menuItem);
}
}

private static void DKGroupToMAItems(GameObject parent, MenuGroup menuGroup)
{
foreach (var item in menuGroup)
{
DKToMAMenuItem(parent, item);
}
}

public override void Flush()
{
if (!_ctx.AvatarGameObject.TryGetComponent<VRCAvatarDescriptor>(out var avatarDesc))
Expand All @@ -135,7 +170,7 @@ public override void Flush()
return;
}

var dkMaRootObj = new GameObject("DKMA");
var dkMaRootObj = new GameObject("DKMAMenu");
dkMaRootObj.transform.SetParent(_ctx.AvatarGameObject.transform);

foreach (var kvp in _buffer)
Expand Down Expand Up @@ -170,14 +205,7 @@ public override void Flush()
maGroup.targetObject = menuObj;

// add menu items
foreach (var item in items)
{
var maItemObj = new GameObject(item.Name);
maItemObj.transform.SetParent(maGroup.transform);

var maItem = maItemObj.AddComponent<ModularAvatarMenuItem>();
// TODO
}
DKGroupToMAItems(menuObj, items);
}
}

Expand Down
Loading

0 comments on commit e513d35

Please sign in to comment.