Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add submenu for GameResource #54

Open
bub-bl opened this issue Nov 12, 2023 · 1 comment
Open

Add submenu for GameResource #54

bub-bl opened this issue Nov 12, 2023 · 1 comment

Comments

@bub-bl
Copy link
Contributor

bub-bl commented Nov 12, 2023

Add a way to add few game resource in the same category

[GameResource(Category = "MyCategory", ...)] does not working

image

@bub-bl
Copy link
Contributor Author

bub-bl commented Nov 13, 2023

@garrynewman

I can't create a pull request with code for this fix on https://github.com/sboxgame
This code fix this issue:

  • Go in file \sbox\addons\tools\code\CreateAsset.cs
  • Go at line 84
  • 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 );
			} );

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant