Open bub-bl opened 11 months ago
@garrynewman
I can't create a pull request with code for this fix on https://github.com/sboxgame This code fix this issue:
Replace the following code:
menu.AddOption( $"New {gameResource.Name}..", gameResource.Icon, () =>
{
var fd = new FileDialog( null );
fd.Title = $"Create {gameResource.Name}";
fd.Directory = folder.FullName;
fd.DefaultSuffix = $".{gameResource.Extension}";
fd.SelectFile( $"untitled.{gameResource.Extension}" );
fd.SetFindFile();
fd.SetModeSave();
fd.SetNameFilter( $"{gameResource.Name} (*.{gameResource.Extension})" );
if ( !fd.Execute() )
return;
CreateNew( fd.SelectedFile );
} );
With this code
// Create sub menu from category propery if is not empty
var subMenu = string.IsNullOrWhiteSpace(gameResource.Category)
? menu
: menu.FindOrCreateMenu(gameResource.Category);
subMenu.AddOption( $"New {gameResource.Name}..", gameResource.Icon, () =>
{
var fd = new FileDialog( null );
fd.Title = $"Create {gameResource.Name}";
fd.Directory = folder.FullName;
fd.DefaultSuffix = $".{gameResource.Extension}";
fd.SelectFile( $"untitled.{gameResource.Extension}" );
fd.SetFindFile();
fd.SetModeSave();
fd.SetNameFilter( $"{gameResource.Name} (*.{gameResource.Extension})" );
if ( !fd.Execute() )
return;
CreateNew( fd.SelectedFile );
} );
Add a way to add few game resource in the same category
[GameResource(Category = "MyCategory", ...)]
does not working