-
Notifications
You must be signed in to change notification settings - Fork 88
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 infrastructure for embedding Win32 icons #308
Closed
Closed
Changes from all commits
Commits
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
Binary file not shown.
This file contains 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,7 @@ | ||
namespace osu.Game.Resources.Icons | ||
{ | ||
public static class Icons | ||
{ | ||
public static Win32Icon Lazer => new Win32Icon(101); | ||
} | ||
} |
This file contains 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,4 @@ | ||
#include <winnt.rh> | ||
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL | ||
|
||
101 ICON "101-Lazer.ico" |
Binary file not shown.
This file contains 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,12 @@ | ||
# How to generate `Icons.res` | ||
|
||
1. Open `Developer PowerShell for VS 2022` | ||
2. `cd` into this directory | ||
3. Run `RC.exe /v Icons.rc` | ||
|
||
# Adding new icons | ||
|
||
1. Put the `.ico` file with a reasonable name into this folder | ||
2. Open `Icons.rc` as a text file and add the relevant lines | ||
3. Add the C# definition to `Icons.cs` | ||
4. Regenerate `Icons.res` |
This file contains 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,29 @@ | ||
using System.Reflection; | ||
|
||
namespace osu.Game.Resources.Icons | ||
{ | ||
public class Win32Icon | ||
{ | ||
public readonly Assembly Assembly; | ||
public readonly int Id; | ||
|
||
/// <summary> | ||
/// String that can be used with the <c>DefaultIcon</c> key in the registry to point to this icon. | ||
/// </summary> | ||
// The icon id needs to be negative, see https://devblogs.microsoft.com/oldnewthing/20100505-00/?p=14153 | ||
public string RegistryString => $"{Assembly.Location},{-Id}"; | ||
|
||
public override string ToString() => RegistryString; | ||
|
||
public Win32Icon(Assembly assembly, int id) | ||
{ | ||
Assembly = assembly; | ||
Id = id; | ||
} | ||
|
||
internal Win32Icon(int id) | ||
: this(OsuResources.ResourceAssembly, id) | ||
{ | ||
} | ||
} | ||
} |
This file contains 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.
So my primary question here would be.......... can we skip all of this legacy nonsense and just use plain ICO files?
I'd prefer that we didn't have to use some win32 resource incantations and some executables that are only available on windows and also only if you have visual studio enabled.
I would much rather put the
.ico
assets directly inosu.Game.Desktop
and point the registry entries at a plain ICO file rather than deal with whatever this thing is. The fact that this is having to cite a Raymond Chen blogpost is a red flag in my eyes in that this is underdocumented legacy cruft, because if that is the best available citation then oh boy.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.
In fact as far as I can tell even microsoft doesn't wanna deal with this stuff anymore:
The above is a VS Code
.md
file association. It points at a plain.ico
.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.
I agree, would make things simpler.
I tried including the icons as
Content
and it seems to work well. I just tested this with velopack and a sample app, and the icons are available in the install directory.