-
Notifications
You must be signed in to change notification settings - Fork 20
Add tool filter #142
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
Merged
Merged
Add tool filter #142
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
08fcfdd
Add tool filters
emyhrberg f9d96bf
Fix tool filter icon and description
emyhrberg 1180cb4
Fix tool description again
emyhrberg f842279
Merge branch 'master' into AddToolFilter
emyhrberg ede1375
Merge branch 'master' into AddToolFilter
ScalarVector1 226a3c1
Merge branch 'master' into AddToolFilter
ScalarVector1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| using DragonLens.Content.GUI; | ||
| using DragonLens.Content.Tools; | ||
|
|
||
| namespace DragonLens.Content.Filters.ToolFilters | ||
| { | ||
| internal class ToolModFilter : Filter | ||
| { | ||
| public Mod mod; | ||
|
|
||
| public ToolModFilter(Mod mod) : base(null, "", n => FilterByMod(n, mod)) | ||
| { | ||
| this.mod = mod; | ||
| isModFilter = true; | ||
| } | ||
|
|
||
| public override string Name => mod.DisplayName; | ||
|
|
||
| public override string Description => CustomizeTool.GetText("Filters.Mod.Description", mod.DisplayName); | ||
|
|
||
| public static bool FilterByMod(BrowserButton button, Mod mod) | ||
| { | ||
| if (button is ToolBrowserButton) | ||
| { | ||
| var tb = button as ToolBrowserButton; | ||
|
|
||
| if (tb.tool.Mod != null && tb.tool.Mod == mod) | ||
| return false; | ||
| } | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| public override void Draw(SpriteBatch spriteBatch, Rectangle target) | ||
| { | ||
| Texture2D tex = null; | ||
|
|
||
| string path = $"{mod.Name}/icon_small"; | ||
|
|
||
| if (ModContent.HasAsset(path)) | ||
| tex = ModContent.Request<Texture2D>(path).Value; | ||
|
|
||
| if (tex != null) | ||
| { | ||
| int widest = tex.Width > tex.Height ? tex.Width : tex.Height; | ||
| spriteBatch.Draw(tex, target.Center.ToVector2(), null, Color.White, 0, tex.Size() / 2f, target.Width / (float)widest, 0, 0); | ||
| } | ||
| else | ||
| { | ||
| Utils.DrawBorderString(spriteBatch, mod.DisplayName[..2], target.Center.ToVector2(), Color.White, 1, 0.5f, 0.4f); | ||
| } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this would override if DL ever adds an icon_small, is this the intended behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally if this does happen the external logic checkifn tfor the mod is removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, used vanilla asset for DragonLens tools