Skip to content

Commit 7e8fea4

Browse files
committed
fix texture scaling
1 parent 83047b7 commit 7e8fea4

File tree

5 files changed

+20
-6
lines changed

5 files changed

+20
-6
lines changed

src/main/java/net/modfest/ballotbox/client/BallotBoxClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public void onInitializeClient() {
3838
BallotBoxKeybinds.init();
3939

4040

41-
var lateModify = Identifier.of("ballotbox", "late");
41+
var lateModify = Identifier.of(BallotBox.ID, "late");
4242
ScreenEvents.AFTER_INIT.addPhaseOrdering(Event.DEFAULT_PHASE, lateModify);
4343
ScreenEvents.AFTER_INIT.register(lateModify, (client, screen, scaledWidth, scaledHeight) -> {
4444
if (screen instanceof ApplyModifications applyModifications) applyModifications.ballotbox$applyModifications();

src/main/java/net/modfest/ballotbox/client/VotingScreen.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
1515
import net.fabricmc.loader.api.FabricLoader;
1616
import net.fabricmc.loader.api.ModContainer;
17+
import net.minecraft.client.MinecraftClient;
1718
import net.minecraft.client.gui.DrawContext;
1819
import net.minecraft.client.texture.NativeImageBackedTexture;
20+
import net.minecraft.client.texture.Sprite;
1921
import net.minecraft.text.Text;
2022
import net.minecraft.util.Formatting;
2123
import net.minecraft.util.Identifier;
@@ -47,15 +49,14 @@ public class VotingScreen extends SpruceScreen {
4749
"community"
4850
);
4951

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

5454
protected final Multimap<String, String> previousSelections = HashMultimap.create();
5555
protected final Multimap<String, String> selections = HashMultimap.create();
5656
protected List<VotingCategory> categories = new ArrayList<>();
5757
protected List<VotingOption> options = new ArrayList<>();
5858
protected boolean loaded = false;
59+
protected Sprite lockupSprite = null;
5960

6061
protected int sidePanelWidth;
6162
protected int sidePanelVerticalPadding;
@@ -70,6 +71,7 @@ public VotingScreen() {
7071
@Override
7172
protected void init() {
7273
super.init();
74+
this.lockupSprite = MinecraftClient.getInstance().getGuiAtlasManager().getSprite(LOCKUP_TEXTURE);
7375
if (loaded) {
7476
initLoaded();
7577
}
@@ -109,9 +111,12 @@ public void renderBackground(DrawContext context, int mouseX, int mouseY, float
109111
}
110112

111113
public void renderLockup(DrawContext context) {
114+
if (lockupSprite == null) return;
112115
RenderSystem.enableBlend();
113-
int drawHeight = sidePanelWidth * LOCKUP_TEXTURE_HEIGHT / LOCKUP_TEXTURE_WIDTH;
114-
context.drawTexture(LOCKUP_TEXTURE, 0, (sidePanelVerticalPadding - drawHeight) / 2, sidePanelWidth, drawHeight, 0, 0, LOCKUP_TEXTURE_WIDTH, LOCKUP_TEXTURE_HEIGHT, LOCKUP_TEXTURE_WIDTH, LOCKUP_TEXTURE_HEIGHT);
116+
int texHeight = lockupSprite.getContents().getHeight();
117+
int texWidth = lockupSprite.getContents().getWidth();
118+
int drawHeight = sidePanelWidth * texHeight / texWidth;
119+
context.drawGuiTexture(LOCKUP_TEXTURE, 0, (sidePanelVerticalPadding - drawHeight) / 2, sidePanelWidth, drawHeight);
115120
RenderSystem.disableBlend();
116121
}
117122

2.79 KB
Loading
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"gui": {
3+
"scaling": {
4+
"type": "stretch",
5+
"width": 512,
6+
"height": 128
7+
}
8+
}
9+
}
Binary file not shown.

0 commit comments

Comments
 (0)