Skip to content

Commit

Permalink
extract useful constants to client
Browse files Browse the repository at this point in the history
  • Loading branch information
sisby-folk committed Jul 12, 2024
1 parent a587034 commit e032d3d
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx1G
org.gradle.parallel=true

# Mod Properties
version=1.5.2
version=1.5.3
maven_group=net.modfest
archives_base_name=scatteredshards

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
import net.modfest.scatteredshards.networking.ScatteredShardsNetworking;

public class ScatteredShardsClient implements ClientModInitializer {
public static final int ICON_Y_OFFSET = 4;
public static final boolean DRAW_MINI_ICONS = true;
public static final int LEFT = 0xFF_778888;
public static final int RIGHT_TOP = 0xFF_777777;
public static final int RIGHT_BOTTOM = 0xFF_555555;

public static final String SHARD_MODIFY_TOAST_KEY = "toast.scattered_shards.shard_mod";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.modfest.scatteredshards.client.render;

import net.modfest.scatteredshards.client.ScatteredShardsClient;
import org.joml.AxisAngle4f;
import org.joml.Quaternionf;
import org.joml.Vector3f;
Expand Down Expand Up @@ -169,7 +170,7 @@ public void render(ShardBlockEntity entity, float tickDelta, MatrixStack matrice
float ypx = 1/32f * cardHeight;

shard.icon().ifLeft( stack -> {
matrices.translate(0, 4*ypx, -0.005f); //extra -0.002 here to prevent full-cubes from zfighting the card
matrices.translate(0, ScatteredShardsClient.ICON_Y_OFFSET*ypx, -0.005f); //extra -0.002 here to prevent full-cubes from zfighting the card
matrices.scale(-0.38f, 0.38f, 0.001f /*0.6f*/);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import net.modfest.scatteredshards.api.ShardCollection;
import net.modfest.scatteredshards.api.ShardLibrary;
import net.modfest.scatteredshards.api.shard.Shard;
import net.modfest.scatteredshards.client.ScatteredShardsClient;
import net.modfest.scatteredshards.client.screen.widget.WLeftRightPanel;
import net.modfest.scatteredshards.client.screen.widget.WShardPanel;
import net.modfest.scatteredshards.client.screen.widget.WShardSetPanel;
Expand Down Expand Up @@ -70,7 +71,7 @@ private void configurePanel(Identifier setId, WShardSetPanel panel) {

@Override
public void addPainters() {
selectorPanel.setBackgroundPainter(BackgroundPainter.createColorful(0xFF_778888));
selectorPanel.setBackgroundPainter(BackgroundPainter.createColorful(ScatteredShardsClient.LEFT));
}

public static class Screen extends CottonClientScreen {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import net.modfest.scatteredshards.api.ScatteredShardsAPI;
import net.modfest.scatteredshards.api.shard.Shard;
import net.modfest.scatteredshards.api.shard.ShardType;
import net.modfest.scatteredshards.client.ScatteredShardsClient;

public class WMiniShard extends WWidget {
private static final Identifier MINI_OUTLINE = ScatteredShards.id("/textures/gui/shards/mini_outline.png");
Expand Down Expand Up @@ -46,7 +47,7 @@ public void paint(DrawContext context, int x, int y, int mouseX, int mouseY) {
int color = (isCollected) ? 0xFF_FFFFFF : 0xFF_668866;
float opacity = (isCollected) ? 1.0f : 0.6f;
ScreenDrawing.texturedRect(context, x, y, 12, 16, tex, color, opacity);
if (isCollected) {
if (isCollected && ScatteredShardsClient.DRAW_MINI_ICONS) {
//Maybe draw a teeny tiny icon
shard.icon().ifLeft((it) -> {
context.getMatrices().push();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import net.modfest.scatteredshards.api.ScatteredShardsAPI;
import net.modfest.scatteredshards.api.shard.Shard;
import net.modfest.scatteredshards.api.shard.ShardType;
import net.modfest.scatteredshards.client.ScatteredShardsClient;
import net.modfest.scatteredshards.client.screen.widget.scalable.WScaledLabel;
import net.modfest.scatteredshards.client.screen.widget.scalable.WScaledText;
import net.modfest.scatteredshards.client.screen.widget.scalable.WShardIcon;
Expand Down Expand Up @@ -131,7 +132,7 @@ public WShardPanel hideWithMessage(Text message) {
private int getLayoutWidth() {
return this.getWidth() - insets.left() - insets.right();
}

public WShardPanel() {
this.shardType = ShardType.MISSING;
this.width = 124;
Expand All @@ -146,7 +147,7 @@ public WShardPanel() {
int cardX = ((this.getLayoutWidth()) / 2) - (12 * cardScale);
add(backing, cardX, 40, 24*cardScale, 32*cardScale);

add(icon, cardX + (4 * cardScale), 40 + (4 * cardScale), 16 * cardScale, 16 * cardScale);
add(icon, cardX + (4 * cardScale), 40 + (ScatteredShardsClient.ICON_Y_OFFSET * cardScale), 16 * cardScale, 16 * cardScale);


add(lore, 0, 113, getLayoutWidth(), 32);
Expand Down Expand Up @@ -197,7 +198,7 @@ public void addPainters() {
context.setShaderColor(1, 1, 1, 1);
ScreenDrawing.drawGuiPanel(context, left, top, panel.getWidth(), panel.getHeight());
ScreenDrawing.drawBeveledPanel(context, left+4, top+4, panel.getWidth()-8, panel.getHeight()-8);
context.fillGradient(left+5, top+5, left+5+panel.getWidth()-10, top+5+panel.getHeight()-10, 0xFF_777777, 0xFF_555555);
context.fillGradient(left+5, top+5, left+5+panel.getWidth()-10, top+5+panel.getHeight()-10, ScatteredShardsClient.RIGHT_TOP, ScatteredShardsClient.RIGHT_BOTTOM);
});
}

Expand Down

0 comments on commit e032d3d

Please sign in to comment.