Skip to content

Commit

Permalink
improve mod icon matching
Browse files Browse the repository at this point in the history
  • Loading branch information
sisby-folk committed Jul 7, 2024
1 parent 233804e commit c4d106f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 25 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ org.gradle.configureondemand=true
# Enable advanced multi-module optimizations (share tiny-remaper instance between projects)
fabric.loom.multiProjectOptimisation=true
# Mod Properties
baseVersion = 0.1.1
baseVersion = 0.1.2
defaultBranch = 1.21
branch = 1.21
9 changes: 5 additions & 4 deletions src/main/java/net/modfest/ballotbox/client/VotingScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,17 @@ public VotingOptionButtonWidget(Position position, int width, int height, Voting
selected = selections.containsEntry(category.id(), option.id());
this.prohibited = prohibited;
if (!modIconChecked.contains(option.id())) {
FabricLoader.getInstance().getModContainer(option.id()).ifPresent(mod -> {
mod.getMetadata().getIconPath(16).ifPresent(iconPath -> mod.findPath(iconPath).ifPresent(path -> {
FabricLoader.getInstance().getModContainer(option.id())
.or(() -> FabricLoader.getInstance().getModContainer(option.id().replace('_', '-')))
.or(() -> FabricLoader.getInstance().getModContainer(option.id().replace("_", "")))
.ifPresent(mod -> mod.getMetadata().getIconPath(16).ifPresent(iconPath -> mod.findPath(iconPath).ifPresent(path -> {
try (InputStream inputStream = Files.newInputStream(path)) {
Identifier textureId = Identifier.of(BallotBox.ID, mod.getMetadata().getId() + "_icon");
modIconCache.put(option.id(), textureId);
this.client.getTextureManager().registerTexture(textureId, new NativeImageBackedTexture(NativeImage.read(inputStream)));
} catch (IOException ignored) {
}
}));
});
})));
modIconChecked.add(option.id());
}
texture = modIconCache.get(option.id());
Expand Down
20 changes: 0 additions & 20 deletions src/main/resources/test/categories.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,5 @@
"description": "Mods pushing the medium with fresh, surprising ideas.",
"type": "community",
"limit": 3
},
{
"id": "most_polished",
"name": "Most Polished",
"description": "Mods with a polished, complete sheen.",
"type": "community",
"prohibitions": [
"most_potential"
],
"limit": 3
},
{
"id": "most_potential",
"name": "Most Potential",
"description": "Mods whose best features lay in their future.",
"type": "community",
"prohibitions": [
"most_polished"
],
"limit": 3
}
]

0 comments on commit c4d106f

Please sign in to comment.