Allow only valid characters when creating collections.

This commit is contained in:
Ottermandias 2022-07-21 10:07:20 +02:00
parent f808c8a471
commit c2bc8252f1
3 changed files with 10 additions and 4 deletions

View file

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using OtterGui.Filesystem;
using Penumbra.Mods;
namespace Penumbra.Collections;
@ -25,7 +26,7 @@ public partial class ModCollection
// Get the first two letters of a collection name and its Index (or None if it is the empty collection).
public string AnonymizedName
=> this == Empty ? Empty.Name : Name.Length > 2 ? $"{Name[..2]}... ({Index})" : $"{Name} ({Index})";
=> this == Empty ? Empty.Name : Name.Length > 2 ? $"{Name[ ..2 ]}... ({Index})" : $"{Name} ({Index})";
public int Version { get; private set; }
public int Index { get; private set; } = -1;
@ -94,6 +95,11 @@ public partial class ModCollection
public ModCollection Duplicate( string name )
=> new(name, this);
// Check if a name is valid to use for a collection.
// Does not check for uniqueness.
public static bool IsValidName( string name )
=> name.Length > 0 && name.All( c => !c.IsInvalidAscii() && c is not '|' && !c.IsInvalidInPath() );
// Remove all settings for not currently-installed mods.
public void CleanUnavailableSettings()
{