Min length library (#3509)

Co-authored-by: 766974616c79 <100430077+766974616c79@users.noreply.github.com>
This commit is contained in:
sboxbot
2025-11-30 19:16:55 +00:00
committed by GitHub
parent 173ac80dfa
commit b2b8612055
3 changed files with 7 additions and 3 deletions

View File

@@ -30,7 +30,7 @@ public class ProjectConfig
/// </summary>
[Display( GroupName = "Setup", Order = -100, Name = "Title", Description = "The human readable title, for example \"Sandbox\", \"Counter - Strike\"" )]
[MaxLength( 32 )]
[MinLength( 2 )]
[MinLength( 3 )]
public string Title { get; set; }
/// <summary>

View File

@@ -45,7 +45,7 @@ public partial class Dialog : Widget
/// <summary>
/// Ask for a string
/// </summary>
public static void AskString( Action<string> OnSuccess, string question, string okay = "Okay", string cancel = "Cancel", string initialName = "", string title = "Input required" )
public static void AskString( Action<string> OnSuccess, string question, string okay = "Okay", string cancel = "Cancel", string initialName = "", string title = "Input required", int minLength = 0 )
{
var modal = new TextDialog();
modal.Window.SetWindowIcon( "question_mark" );
@@ -55,6 +55,7 @@ public partial class Dialog : Widget
modal.OkayButton.Text = okay;
modal.OkayButton.Enabled = !string.IsNullOrWhiteSpace( initialName );
modal.CancelButton.Text = cancel;
modal.MinLength = minLength;
modal.OnSuccess = OnSuccess;
modal.Show();
modal.LineEdit.Text = initialName;
@@ -108,6 +109,8 @@ public partial class Dialog : Widget
public LineEdit LineEdit { get; private set; }
public Label Label { get; private set; }
public int MinLength { get; set; }
bool WantsText = true;
public TextDialog( bool wantsText = true )
@@ -165,6 +168,7 @@ public partial class Dialog : Widget
{
var valid = true;
if ( string.IsNullOrWhiteSpace( LineEdit.Text ) ) valid = false;
if ( LineEdit.Text.Trim().Length < MinLength ) valid = false;
if ( !WantsText ) valid = true;
OkayButton.Enabled = valid;

View File

@@ -226,7 +226,7 @@ public class LibraryManagerDock : Widget
void CreateNewLibrary()
{
Dialog.AskString( CreateNewLibrary, "What would you like to call your new library?", "Create", title: "Create a Library" );
Dialog.AskString( CreateNewLibrary, "What would you like to call your new library?", "Create", title: "Create a Library", minLength: 2 );
}
void CreateNewLibrary( string libraryName )