mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 21:55:01 +07:00
correctly working icon replacement
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 347 KiB |
Binary file not shown.
@@ -136,7 +136,6 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<None Include="ReadMe.txt" />
|
||||
<None Include="small.ico" />
|
||||
<None Include="splash.bmp" />
|
||||
<None Include="WinLauncher.ico" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -16,9 +16,6 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="ReadMe.txt" />
|
||||
<None Include="small.ico">
|
||||
<Filter>Resource Files</Filter>
|
||||
</None>
|
||||
<None Include="WinLauncher.ico">
|
||||
<Filter>Resource Files</Filter>
|
||||
</None>
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 23 KiB |
@@ -33,6 +33,25 @@ public class IconResourceInjector {
|
||||
IconFile iconFile = new IconFile(file);
|
||||
iconFile.read();
|
||||
|
||||
//updateGroupIcon(root, iconId, iconFile);
|
||||
|
||||
DirectoryEntry iconsDir = root.findSubDir("IRD3");
|
||||
Level iconFileLevel = (Level) iconFile.getMember("Level");
|
||||
ArrayList icons = iconFileLevel.getMembers();
|
||||
if (icons.size() == iconsDir.getSubDirs().size()) {
|
||||
for (int i = 0; i < icons.size(); i++) {
|
||||
DirectoryEntry subDirIcon = iconsDir.findSubDir("IRD" + (i+1));
|
||||
IconDirectory iconDirectory = (IconDirectory) iconFileLevel.getMembers().get(i);
|
||||
RawResource rawResource = subDirIcon.getRawResource(0);
|
||||
rawResource.setBytes(iconDirectory.getRawBytes());
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new IOException("Count of icons in template file doesn't match the count of icons in provided icon file");
|
||||
}
|
||||
}
|
||||
|
||||
private void updateGroupIcon(DirectoryEntry root, String iconId, IconFile iconFile) throws IOException {
|
||||
DirectoryEntry subDirGroupIcon = root.findSubDir("IRD14").findSubDir(iconId);
|
||||
RawResource groupIcon = subDirGroupIcon.getRawResource(0);
|
||||
|
||||
@@ -51,18 +70,6 @@ public class IconResourceInjector {
|
||||
DataOutputStream stream = new DataOutputStream(bytesStream);
|
||||
groupIconResource.write(stream);
|
||||
groupIcon.getBytes().setBytes(bytesStream.toByteArray());
|
||||
|
||||
DirectoryEntry iconsDir = root.findSubDir("IRD3");
|
||||
DirectoryEntry subDirIcon = iconsDir.findSubDir("IRD1");
|
||||
RawResource rawResource = subDirIcon.getRawResource(0);
|
||||
Level iconFileLevel = (Level) iconFile.getMember("Level");
|
||||
IconDirectory iconDirectory = (IconDirectory) iconFileLevel.getMembers().get(0);
|
||||
rawResource.setBytes(iconDirectory.getRawBytes());
|
||||
|
||||
ArrayList icons = iconFileLevel.getMembers();
|
||||
for (int i = 1; i < icons.size(); i++) {
|
||||
insertIcon(iconsDir, (IconDirectory) icons.get(i), i);
|
||||
}
|
||||
}
|
||||
|
||||
private void insertIcon(DirectoryEntry iconsDir, IconDirectory iconDirectory, int index) {
|
||||
|
||||
@@ -91,7 +91,7 @@ public class LauncherGenerator {
|
||||
bmpRes.setBytes(bitmapData);
|
||||
}
|
||||
|
||||
public void injectIcon(String name, final InputStream iconStream) throws IOException {
|
||||
public void injectIcon(int id, final InputStream iconStream) throws IOException {
|
||||
File f = File.createTempFile("launcher", "ico");
|
||||
Files.copy(new InputSupplier<InputStream>() {
|
||||
@Override
|
||||
@@ -100,6 +100,6 @@ public class LauncherGenerator {
|
||||
}
|
||||
}, f);
|
||||
IconResourceInjector iconInjector = new IconResourceInjector();
|
||||
iconInjector.injectIcon(f, myRoot, "IRD101");
|
||||
iconInjector.injectIcon(f, myRoot, "IRD" + id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ public class LauncherGeneratorMain {
|
||||
}
|
||||
|
||||
generator.injectBitmap(resourceIDs.get("IDB_SPLASH"), splashBmpStream.toByteArray());
|
||||
generator.injectIcon(icoUrl, iconStream);
|
||||
generator.injectIcon(resourceIDs.get("IDI_WINLAUNCHER"), iconStream);
|
||||
|
||||
generator.generate();
|
||||
} catch (IOException e) {
|
||||
|
||||
Reference in New Issue
Block a user