mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-13 12:14:17 +01:00
Allow only valid characters when creating collections.
This commit is contained in:
parent
f808c8a471
commit
c2bc8252f1
3 changed files with 10 additions and 4 deletions
|
|
@ -79,7 +79,7 @@ public partial class ModCollection
|
||||||
// and no existing collection results in the same filename as name.
|
// and no existing collection results in the same filename as name.
|
||||||
public bool CanAddCollection( string name, out string fixedName )
|
public bool CanAddCollection( string name, out string fixedName )
|
||||||
{
|
{
|
||||||
if( name.Length == 0 )
|
if( !IsValidName( name ) )
|
||||||
{
|
{
|
||||||
fixedName = string.Empty;
|
fixedName = string.Empty;
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using OtterGui.Filesystem;
|
||||||
using Penumbra.Mods;
|
using Penumbra.Mods;
|
||||||
|
|
||||||
namespace Penumbra.Collections;
|
namespace Penumbra.Collections;
|
||||||
|
|
@ -94,6 +95,11 @@ public partial class ModCollection
|
||||||
public ModCollection Duplicate( string name )
|
public ModCollection Duplicate( string name )
|
||||||
=> new(name, this);
|
=> 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.
|
// Remove all settings for not currently-installed mods.
|
||||||
public void CleanUnavailableSettings()
|
public void CleanUnavailableSettings()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ public partial class ConfigWindow
|
||||||
+ "You can use multiple collections to quickly switch between sets of mods." );
|
+ "You can use multiple collections to quickly switch between sets of mods." );
|
||||||
|
|
||||||
// Creation buttons.
|
// Creation buttons.
|
||||||
var tt = _canAddCollection ? string.Empty : "Please enter a unique name before creating a collection.";
|
var tt = _canAddCollection ? string.Empty : "Please enter a unique name only consisting of symbols valid in a path but no '|' before creating a collection.";
|
||||||
if( ImGuiUtil.DrawDisabledButton( "Create New Empty Collection", Vector2.Zero, tt, !_canAddCollection ) )
|
if( ImGuiUtil.DrawDisabledButton( "Create New Empty Collection", Vector2.Zero, tt, !_canAddCollection ) )
|
||||||
{
|
{
|
||||||
CreateNewCollection( false );
|
CreateNewCollection( false );
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue