Skip to content

Commit

Permalink
Use constant for white color hexcode
Browse files Browse the repository at this point in the history
  • Loading branch information
Sturmlilie committed May 18, 2020
1 parent aa6f663 commit a204799
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.mojang.blaze3d.platform.GlStateManager;
import li.cil.tis3d.api.util.RenderLayerAccess;
import li.cil.tis3d.api.util.RenderUtil;
import li.cil.tis3d.util.ColorUtils;
import it.unimi.dsi.fastutil.ints.Int2IntMap;
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
import net.minecraft.client.MinecraftClient;
Expand Down Expand Up @@ -72,7 +73,7 @@ public void drawString(final CharSequence value, final int maxChars) {
public void drawString(final MatrixStack.Entry matrices, final VertexConsumer vc,
int light, int overlay,
final CharSequence value) {
drawString(matrices, vc, light, overlay, 0xFFFFFFFF, value, value.length());
drawString(matrices, vc, light, overlay, ColorUtils.WHITE, value, value.length());
}

public void drawString(final MatrixStack.Entry matrices, final VertexConsumer vc,
Expand All @@ -84,7 +85,7 @@ public void drawString(final MatrixStack.Entry matrices, final VertexConsumer vc
public void drawString(final MatrixStack.Entry matrices, final VertexConsumer vc,
int light, int overlay,
final CharSequence value, final int maxChars) {
drawString(matrices, vc, light, overlay, 0xFFFFFFFF, value, maxChars);
drawString(matrices, vc, light, overlay, ColorUtils.WHITE, value, maxChars);
}

public void drawString(final MatrixStack.Entry matrices, final VertexConsumer vc,
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/li/cil/tis3d/common/module/ExecutionModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import li.cil.tis3d.common.module.execution.MachineState;
import li.cil.tis3d.common.module.execution.compiler.Compiler;
import li.cil.tis3d.common.module.execution.compiler.ParseException;
import li.cil.tis3d.util.ColorUtils;
import li.cil.tis3d.util.EnumUtils;
import li.cil.tis3d.util.NBTIds;
import net.fabricmc.api.EnvType;
Expand Down Expand Up @@ -393,7 +394,7 @@ private void renderState(final MatrixStack matrices, final VertexConsumerProvide
final int page = currentLine / maxLines;
final int offset = page * maxLines;

int color = 0xFFFFFFFF;
int color = ColorUtils.WHITE;
int currentLineBgColor = color;
// Some bookkeeping so we can draw the current-line background
// at the correct y offset later
Expand All @@ -413,7 +414,7 @@ private void renderState(final MatrixStack matrices, final VertexConsumerProvide

color = 0xFF000000;
} else {
color = 0xFFFFFFFF;
color = ColorUtils.WHITE;
}

fontRenderer.drawString(matrices.peek(), vcFont, light, overlay,
Expand All @@ -428,7 +429,7 @@ private void renderState(final MatrixStack matrices, final VertexConsumerProvide

final VertexConsumer vcColor = vcp.getBuffer(RenderLayer.getSolid());
drawLine(matrices.peek(), vcColor, light, overlay,
0xFFFFFFFF, 1);
ColorUtils.WHITE, 1);

if (currentLineOffset != -1) {
// Draw current line marker behind text
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/li/cil/tis3d/common/module/KeypadModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import li.cil.tis3d.api.prefab.module.AbstractModuleWithRotation;
import li.cil.tis3d.api.util.RenderUtil;
import li.cil.tis3d.client.init.Textures;
import li.cil.tis3d.util.ColorUtils;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.render.RenderLayer;
Expand Down Expand Up @@ -291,6 +292,6 @@ private void drawButtonOverlay(final MatrixStack matrices, final VertexConsumer
matrices.translate(0, 0, 0.005f / 2);
RenderUtil.drawColorQuad(matrices.peek(), vcColor,
x - delta, y - delta, w + 2*delta, h + 2*delta,
0xFFFFFFFF, light, overlay);
ColorUtils.WHITE, light, overlay);
}
}
3 changes: 2 additions & 1 deletion src/main/java/li/cil/tis3d/common/module/TerminalModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import li.cil.tis3d.client.init.Textures;
import li.cil.tis3d.client.render.font.AbstractFontRenderer;
import li.cil.tis3d.client.render.font.NormalFontRenderer;
import li.cil.tis3d.util.ColorUtils;
import li.cil.tis3d.util.NBTIds;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
Expand Down Expand Up @@ -347,7 +348,7 @@ private void renderInput(final MatrixStack matrices, final VertexConsumer vcFont
final VertexConsumerProvider vcp,
final int light, final int overlay,
final AbstractFontRenderer fontRenderer, final int textWidth) {
int color = 0xFFFFFFFF;
int color = ColorUtils.WHITE;

matrices.translate(0, 4, 0);

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/li/cil/tis3d/util/ColorUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public final class ColorUtils {
0xFF000000 // 15: Black
};

public static final int WHITE = COLORS[0];

/**
* Get an ARGB color value for the dye color with the specified index.
*
Expand Down

0 comments on commit a204799

Please sign in to comment.