mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2025-01-31 02:32:53 +08:00
Sanitize invalid icons on menu installation (#146)
This commit is contained in:
parent
e7ec5b08b4
commit
2ac191555e
@ -61,7 +61,8 @@ namespace nadena.dev.modular_avatar.core.editor
|
||||
if (!_installTargets.TryGetValue(installer.installTargetMenu, out var targetMenu)) return;
|
||||
if (_installTargets.ContainsKey(installer.menuToAppend)) return;
|
||||
|
||||
targetMenu.controls.AddRange(installer.menuToAppend.controls);
|
||||
// Clone before appending to sanitize menu icons
|
||||
targetMenu.controls.AddRange(CloneMenu(installer.menuToAppend).controls);
|
||||
|
||||
while (targetMenu.controls.Count > VRCExpressionsMenu.MAX_CONTROLS)
|
||||
{
|
||||
@ -103,6 +104,20 @@ namespace nadena.dev.modular_avatar.core.editor
|
||||
|
||||
foreach (var control in newMenu.controls)
|
||||
{
|
||||
if (Util.ValidateExpressionMenuIcon(control.icon) != Util.ValidateExpressionMenuIconResult.Success)
|
||||
control.icon = null;
|
||||
|
||||
for (int i = 0; i < control.labels.Length; i++)
|
||||
{
|
||||
var label = control.labels[i];
|
||||
var labelResult = Util.ValidateExpressionMenuIcon(label.icon);
|
||||
if (labelResult != Util.ValidateExpressionMenuIconResult.Success)
|
||||
{
|
||||
label.icon = null;
|
||||
control.labels[i] = label;
|
||||
}
|
||||
}
|
||||
|
||||
if (control.type == VRCExpressionsMenu.Control.ControlType.SubMenu)
|
||||
{
|
||||
control.subMenu = CloneMenu(control.subMenu);
|
||||
|
Loading…
Reference in New Issue
Block a user