Skip to content

Commit e032d3d

Browse files
committed
extract useful constants to client
1 parent a587034 commit e032d3d

File tree

6 files changed

+16
-7
lines changed

6 files changed

+16
-7
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx1G
33
org.gradle.parallel=true
44

55
# Mod Properties
6-
version=1.5.2
6+
version=1.5.3
77
maven_group=net.modfest
88
archives_base_name=scatteredshards
99

src/main/java/net/modfest/scatteredshards/client/ScatteredShardsClient.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
import net.modfest.scatteredshards.networking.ScatteredShardsNetworking;
2020

2121
public class ScatteredShardsClient implements ClientModInitializer {
22+
public static final int ICON_Y_OFFSET = 4;
23+
public static final boolean DRAW_MINI_ICONS = true;
24+
public static final int LEFT = 0xFF_778888;
25+
public static final int RIGHT_TOP = 0xFF_777777;
26+
public static final int RIGHT_BOTTOM = 0xFF_555555;
2227

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

src/main/java/net/modfest/scatteredshards/client/render/ShardBlockEntityRenderer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package net.modfest.scatteredshards.client.render;
22

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

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

175176

src/main/java/net/modfest/scatteredshards/client/screen/ShardTabletGuiDescription.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import net.modfest.scatteredshards.api.ShardCollection;
1717
import net.modfest.scatteredshards.api.ShardLibrary;
1818
import net.modfest.scatteredshards.api.shard.Shard;
19+
import net.modfest.scatteredshards.client.ScatteredShardsClient;
1920
import net.modfest.scatteredshards.client.screen.widget.WLeftRightPanel;
2021
import net.modfest.scatteredshards.client.screen.widget.WShardPanel;
2122
import net.modfest.scatteredshards.client.screen.widget.WShardSetPanel;
@@ -70,7 +71,7 @@ private void configurePanel(Identifier setId, WShardSetPanel panel) {
7071

7172
@Override
7273
public void addPainters() {
73-
selectorPanel.setBackgroundPainter(BackgroundPainter.createColorful(0xFF_778888));
74+
selectorPanel.setBackgroundPainter(BackgroundPainter.createColorful(ScatteredShardsClient.LEFT));
7475
}
7576

7677
public static class Screen extends CottonClientScreen {

src/main/java/net/modfest/scatteredshards/client/screen/widget/WMiniShard.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import net.modfest.scatteredshards.api.ScatteredShardsAPI;
1616
import net.modfest.scatteredshards.api.shard.Shard;
1717
import net.modfest.scatteredshards.api.shard.ShardType;
18+
import net.modfest.scatteredshards.client.ScatteredShardsClient;
1819

1920
public class WMiniShard extends WWidget {
2021
private static final Identifier MINI_OUTLINE = ScatteredShards.id("/textures/gui/shards/mini_outline.png");
@@ -46,7 +47,7 @@ public void paint(DrawContext context, int x, int y, int mouseX, int mouseY) {
4647
int color = (isCollected) ? 0xFF_FFFFFF : 0xFF_668866;
4748
float opacity = (isCollected) ? 1.0f : 0.6f;
4849
ScreenDrawing.texturedRect(context, x, y, 12, 16, tex, color, opacity);
49-
if (isCollected) {
50+
if (isCollected && ScatteredShardsClient.DRAW_MINI_ICONS) {
5051
//Maybe draw a teeny tiny icon
5152
shard.icon().ifLeft((it) -> {
5253
context.getMatrices().push();

src/main/java/net/modfest/scatteredshards/client/screen/widget/WShardPanel.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import net.modfest.scatteredshards.api.ScatteredShardsAPI;
2727
import net.modfest.scatteredshards.api.shard.Shard;
2828
import net.modfest.scatteredshards.api.shard.ShardType;
29+
import net.modfest.scatteredshards.client.ScatteredShardsClient;
2930
import net.modfest.scatteredshards.client.screen.widget.scalable.WScaledLabel;
3031
import net.modfest.scatteredshards.client.screen.widget.scalable.WScaledText;
3132
import net.modfest.scatteredshards.client.screen.widget.scalable.WShardIcon;
@@ -131,7 +132,7 @@ public WShardPanel hideWithMessage(Text message) {
131132
private int getLayoutWidth() {
132133
return this.getWidth() - insets.left() - insets.right();
133134
}
134-
135+
135136
public WShardPanel() {
136137
this.shardType = ShardType.MISSING;
137138
this.width = 124;
@@ -146,7 +147,7 @@ public WShardPanel() {
146147
int cardX = ((this.getLayoutWidth()) / 2) - (12 * cardScale);
147148
add(backing, cardX, 40, 24*cardScale, 32*cardScale);
148149

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

151152

152153
add(lore, 0, 113, getLayoutWidth(), 32);
@@ -197,7 +198,7 @@ public void addPainters() {
197198
context.setShaderColor(1, 1, 1, 1);
198199
ScreenDrawing.drawGuiPanel(context, left, top, panel.getWidth(), panel.getHeight());
199200
ScreenDrawing.drawBeveledPanel(context, left+4, top+4, panel.getWidth()-8, panel.getHeight()-8);
200-
context.fillGradient(left+5, top+5, left+5+panel.getWidth()-10, top+5+panel.getHeight()-10, 0xFF_777777, 0xFF_555555);
201+
context.fillGradient(left+5, top+5, left+5+panel.getWidth()-10, top+5+panel.getHeight()-10, ScatteredShardsClient.RIGHT_TOP, ScatteredShardsClient.RIGHT_BOTTOM);
201202
});
202203
}
203204

0 commit comments

Comments
 (0)