2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ authors=ModFest
contributors=Prospector, Sisby folk, acikek
license=MIT
# Mod Version
baseVersion=0.6.2
baseVersion=0.6.3
# Branch Metadata
branch=1.21
tagBranch=1.21
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void onInitializeClient() {
BallotBoxKeybinds.init();


var lateModify = Identifier.of("ballotbox", "late");
var lateModify = Identifier.of(BallotBox.ID, "late");
ScreenEvents.AFTER_INIT.addPhaseOrdering(Event.DEFAULT_PHASE, lateModify);
ScreenEvents.AFTER_INIT.register(lateModify, (client, screen, scaledWidth, scaledHeight) -> {
if (screen instanceof ApplyModifications applyModifications) applyModifications.ballotbox$applyModifications();
Expand Down
16 changes: 11 additions & 5 deletions src/main/java/net/modfest/ballotbox/client/VotingScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.ModContainer;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.texture.NativeImageBackedTexture;
import net.minecraft.client.texture.Sprite;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.Identifier;
Expand Down Expand Up @@ -47,15 +49,14 @@ public class VotingScreen extends SpruceScreen {
"community"
);

public static final Identifier LOCKUP_TEXTURE = Identifier.of("modfest", "textures/art/graphics/lockup-transparent.png");
public static final int LOCKUP_TEXTURE_WIDTH = 1101;
public static final int LOCKUP_TEXTURE_HEIGHT = 256;
public static final Identifier LOCKUP_TEXTURE = Identifier.of(BallotBox.ID, "emblem");

protected final Multimap<String, String> previousSelections = HashMultimap.create();
protected final Multimap<String, String> selections = HashMultimap.create();
protected List<VotingCategory> categories = new ArrayList<>();
protected List<VotingOption> options = new ArrayList<>();
protected boolean loaded = false;
protected Sprite lockupSprite = null;

protected int sidePanelWidth;
protected int sidePanelVerticalPadding;
Expand All @@ -70,6 +71,7 @@ public VotingScreen() {
@Override
protected void init() {
super.init();
this.lockupSprite = MinecraftClient.getInstance().getGuiAtlasManager().getSprite(LOCKUP_TEXTURE);
if (loaded) {
initLoaded();
}
Expand Down Expand Up @@ -109,9 +111,12 @@ public void renderBackground(DrawContext context, int mouseX, int mouseY, float
}

public void renderLockup(DrawContext context) {
if (lockupSprite == null) return;
RenderSystem.enableBlend();
int drawHeight = sidePanelWidth * LOCKUP_TEXTURE_HEIGHT / LOCKUP_TEXTURE_WIDTH;
context.drawTexture(LOCKUP_TEXTURE, 0, (sidePanelVerticalPadding - drawHeight) / 2, sidePanelWidth, drawHeight, 0, 0, LOCKUP_TEXTURE_WIDTH, LOCKUP_TEXTURE_HEIGHT, LOCKUP_TEXTURE_WIDTH, LOCKUP_TEXTURE_HEIGHT);
int texHeight = lockupSprite.getContents().getHeight();
int texWidth = lockupSprite.getContents().getWidth();
int drawHeight = sidePanelWidth * texHeight / texWidth;
context.drawGuiTexture(LOCKUP_TEXTURE, 0, (sidePanelVerticalPadding - drawHeight) / 2, sidePanelWidth, drawHeight);
RenderSystem.disableBlend();
}

Expand Down Expand Up @@ -276,6 +281,7 @@ public void init() {
category.prohibitions().ifPresent(prohibitions -> prohibitions.forEach(prohibition -> prohibitedIds.addAll(selections.get(prohibition))));
addChildren((containerWidth, containerHeight, widgetAdder) -> {
var optionList = new SpruceOptionListWidget(Position.of(this, 1, 0), containerWidth, containerHeight);
options.sort(Comparator.comparing(o -> o.name().toLowerCase()));
for (var optionPairs : Lists.partition(options, 2)) {
var listEntry = OptionEntryAccessor.ballotbox$create(optionList);
for (int i = 0; i < optionPairs.size(); i++) {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"gui": {
"scaling": {
"type": "stretch",
"width": 512,
"height": 128
}
}
}
Binary file not shown.