Skip to content

Commit

Permalink
customizable popup position
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeRNG committed Nov 2, 2023
1 parent b54704a commit d04444c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
24 changes: 24 additions & 0 deletions src/main/java/dev/dfonline/codeclient/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public class Config {
public boolean UseIForLineScope = false;
public boolean CustomBlockBreaking = false;
public boolean ChestPeeker = true;
public int ChestPeekerX = 0;
public int ChestPeekerY = -4;

private void save() {
try {
Expand Down Expand Up @@ -73,6 +75,8 @@ private void save() {
object.addProperty("UseIForLineScope",UseIForLineScope);
object.addProperty("CustomBlockBreaking",CustomBlockBreaking);
object.addProperty("ChestPeeker",ChestPeeker);
object.addProperty("ChestPeekerX",ChestPeekerX);
object.addProperty("ChestPeekerY",ChestPeekerY);
FileManager.writeConfig(object.toString());
} catch (Exception e) {
CodeClient.LOGGER.info("Couldn't save config: " + e);
Expand Down Expand Up @@ -389,6 +393,26 @@ public YetAnotherConfigLib getLibConfig() {
)
.controller(TickBoxControllerBuilder::create)
.build())
.option(Option.createBuilder(int.class)
.name(Text.literal("Preview X Offset"))
.description(OptionDescription.of(Text.literal("How far horizontally the preview popup is")))
.binding(
0,
() -> ChestPeekerX,
opt -> ChestPeekerX = opt
)
.controller(integerOption -> IntegerFieldControllerBuilder.create(integerOption).range(-500,500))
.build())
.option(Option.createBuilder(int.class)
.name(Text.literal("Preview Y Offset"))
.description(OptionDescription.of(Text.literal("How far vertically the preview popup is")))
.binding(
-4,
() -> ChestPeekerY,
opt -> ChestPeekerY = opt
)
.controller(integerOption -> IntegerFieldControllerBuilder.create(integerOption).range(-500,500))
.build())
.build())
.category(ConfigCategory.createBuilder()
.name(Text.literal("AutoJoin"))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dev.dfonline.codeclient.mixin.render.hud;

import dev.dfonline.codeclient.OverlayManager;
import dev.dfonline.codeclient.config.Config;
import dev.dfonline.codeclient.dev.ChestPeeker;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
Expand Down Expand Up @@ -36,8 +37,8 @@ private void onRender(DrawContext context, float tickDelta, CallbackInfo ci) {
}
List<Text> peeker = ChestPeeker.getOverlayText();
if(peeker != null && !peeker.isEmpty()) {
int x = (scaledWidth / 2);
int yOrig = (scaledHeight / 2) - 4;
int x = (scaledWidth / 2) + Config.getConfig().ChestPeekerX;
int yOrig = (scaledHeight / 2) + Config.getConfig().ChestPeekerY;
context.drawTooltip(textRenderer,peeker,x,yOrig);

}
Expand Down

0 comments on commit d04444c

Please sign in to comment.