Skip to content

Commit

Permalink
Added config option to keep clock centered. False by default.
Browse files Browse the repository at this point in the history
  • Loading branch information
samvbeckmann committed Aug 9, 2017
1 parent 7918717 commit 407c833
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
5 changes: 3 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
mod_version=1.3.3
# suppress inspection "UnusedProperty" for whole file
mod_version=1.4.0
minecraft_version=1.11
forge_version=13.19.0.2153
forge_version=13.19.1.2189
mappings_version=snapshot_20161119
17 changes: 14 additions & 3 deletions src/main/java/com/qkninja/clockhud/client/gui/GuiClock.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.qkninja.clockhud.reference.Textures;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
Expand Down Expand Up @@ -48,20 +49,30 @@ public void onRenderExperienceBar(RenderGameOverlayEvent.Post event)

GlStateManager.scale(ConfigValues.scale, ConfigValues.scale, ConfigValues.scale);

int startX = ConfigValues.xCoord + SUN_WIDTH / 2 - (DOT / 2);
int xCoord;
if (ConfigValues.centerClock)
{
ScaledResolution scaled = new ScaledResolution(mc);
xCoord = (int) ((scaled.getScaledWidth() - (BAR_LENGTH + SUN_WIDTH - DOT) * ConfigValues.scale) / (2 * ConfigValues.scale));
} else
{
xCoord = ConfigValues.xCoord;
}

int startX = xCoord + SUN_WIDTH / 2 - (DOT / 2);
int startY = ConfigValues.yCoord + ICON_HEIGHT / 2 - BAR_HEIGHT / 2;

// Draw bar
this.drawTexturedModalRect(startX, startY, 0, 0, BAR_LENGTH, BAR_HEIGHT);

if (isDay()) // Draw sun
{
this.drawTexturedModalRect(ConfigValues.xCoord + getScaledTime(), ConfigValues.yCoord, 0, BAR_HEIGHT,
this.drawTexturedModalRect(xCoord + getScaledTime(), ConfigValues.yCoord, 0, BAR_HEIGHT,
SUN_WIDTH, ICON_HEIGHT);
}
else // Draw moon
{
this.drawTexturedModalRect(ConfigValues.xCoord + (SUN_WIDTH - MOON_WIDTH) / 2 + getScaledTime(),
this.drawTexturedModalRect(xCoord + (SUN_WIDTH - MOON_WIDTH) / 2 + getScaledTime(),
ConfigValues.yCoord, SUN_WIDTH, BAR_HEIGHT, MOON_WIDTH, ICON_HEIGHT);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ public static void init(File configFile)
private static void loadConfiguration()
{
ConfigValues.showDayCount = configuration.getBoolean("showDayCount", Configuration.CATEGORY_GENERAL, true, "Display the day count at the beginning of each day");
ConfigValues.xCoord = configuration.get(Configuration.CATEGORY_GENERAL, "xCoord", 2, "starting x Coordinate of the clock").getInt();
ConfigValues.yCoord = configuration.get(Configuration.CATEGORY_GENERAL, "yCoord", 2, "starting y Coordinate of the clock").getInt();
ConfigValues.scale = configuration.getFloat("scale", Configuration.CATEGORY_GENERAL, .7F, 0F, 3F, "scale of the clock");
ConfigValues.centerClock = configuration.getBoolean("centeredClock", Configuration.CATEGORY_GENERAL, false, "If true, ignore xCoord and always lock the clock the center of the screen");
ConfigValues.xCoord = configuration.get(Configuration.CATEGORY_GENERAL, "xCoord", 2, "Starting x Coordinate of the clock").getInt();
ConfigValues.yCoord = configuration.get(Configuration.CATEGORY_GENERAL, "yCoord", 2, "Starting y Coordinate of the clock").getInt();
ConfigValues.scale = configuration.getFloat("scale", Configuration.CATEGORY_GENERAL, .7F, 0F, 3F, "Scale of the clock");

if (configuration.hasChanged())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class ConfigValues
{
public static boolean guiActive = true;
public static boolean showDayCount = true;
public static boolean centerClock = false;

public static int xCoord = 2;
public static int yCoord = 2;
Expand Down

0 comments on commit 407c833

Please sign in to comment.