add crosshair customization

This commit is contained in:
Sen 2025-07-03 12:45:26 +02:00
parent 9cefe7602b
commit e78bd9cce6
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
5 changed files with 32 additions and 8 deletions

View file

@ -481,6 +481,12 @@ public class Client implements IThreadListener {
public int downfallRange = 4; public int downfallRange = 4;
@Variable(name = "draw_rain_particle_range", category = CVarCategory.RENDER, min = 0, max = 25, display = "Regen-Partikel-Radius") @Variable(name = "draw_rain_particle_range", category = CVarCategory.RENDER, min = 0, max = 25, display = "Regen-Partikel-Radius")
public int rainParticleRange = 10; public int rainParticleRange = 10;
@Variable(name = "crosshair_size", category = CVarCategory.GUI, min = 0, max = 32, display = "Größe des Fadenkreuzes")
public int crosshairSize = 10;
@Variable(name = "crosshair_color_notarget", type = IntType.COLOR, category = CVarCategory.GUI, display = "Fadenkreuz-Farbe (ohne Ziel)")
public int crosshairColorBase = 0xffcfcfcf;
@Variable(name = "crosshair_color_target", type = IntType.COLOR, category = CVarCategory.GUI, display = "Fadenkreuz-Farbe (mit Ziel)")
public int crosshairColorTarget = 0xffffffff;
@Variable(name = "tic_target", category = CVarCategory.SYSTEM, min = 1.0f, max = 1200.0f, callback = TickFunction.class, display = "Tickrate") @Variable(name = "tic_target", category = CVarCategory.SYSTEM, min = 1.0f, max = 1200.0f, callback = TickFunction.class, display = "Tickrate")
public float tpsTarget = 20.0f; public float tpsTarget = 20.0f;
@ -942,9 +948,9 @@ public class Client implements IThreadListener {
if(this.drawDebug) { if(this.drawDebug) {
this.renderWorldDirections((float)this.tick_fraction); this.renderWorldDirections((float)this.tick_fraction);
} }
else { else if(this.crosshairSize > 0) {
Drawing.drawRect(this.fb_x / 2 - 1, this.fb_y / 2 - 16, 2, 32, this.pointed != null && this.pointed.type != ObjectType.MISS ? 0xffffffff : 0xffcfcfcf); Drawing.drawRect(this.fb_x / 2 - 1, this.fb_y / 2 - this.crosshairSize, 2, this.crosshairSize * 2, this.pointed != null && this.pointed.type != ObjectType.MISS ? this.crosshairColorTarget : this.crosshairColorBase);
Drawing.drawRect(this.fb_x / 2 - 16, this.fb_y / 2 - 1, 32, 2, this.pointed != null && this.pointed.type != ObjectType.MISS ? 0xffffffff : 0xffcfcfcf); Drawing.drawRect(this.fb_x / 2 - this.crosshairSize, this.fb_y / 2 - 1, this.crosshairSize * 2, 2, this.pointed != null && this.pointed.type != ObjectType.MISS ? this.crosshairColorTarget : this.crosshairColorBase);
} }
} }
if(this.world != null && this.open == null) { if(this.world != null && this.open == null) {

View file

@ -8,8 +8,11 @@ import client.Client;
import client.gui.element.Dropdown; import client.gui.element.Dropdown;
import client.gui.element.Dropdown.Handle; import client.gui.element.Dropdown.Handle;
import client.gui.element.Element; import client.gui.element.Element;
import client.gui.element.Field;
import client.renderer.Drawing; import client.renderer.Drawing;
import client.renderer.GlState; import client.renderer.GlState;
import client.vars.CVar;
import client.vars.ColorVar;
import client.window.Bind; import client.window.Bind;
import client.window.Button; import client.window.Button;
import client.window.Keysym; import client.window.Keysym;
@ -182,7 +185,12 @@ public abstract class Gui {
} }
protected Element addSelector(String cvar, int x, int y, int w, int h) { protected Element addSelector(String cvar, int x, int y, int w, int h) {
return this.add(this.gm.getVar(cvar).selector(x, y, w, h)); CVar cv = this.gm.getVar(cvar);
if(cv instanceof ColorVar color) {
this.add(color.label(x, y, w));
return this.add(color.editor(x, y, w, h));
}
return this.add(cv.selector(x, y, w, h));
} }
public void draw() { public void draw() {

View file

@ -7,6 +7,11 @@ public class GuiGraphics extends GuiOptions {
public void init(int width, int height) { public void init(int width, int height) {
this.addSelector("draw_downfall_range", 0, 0, 240, 0); this.addSelector("draw_downfall_range", 0, 0, 240, 0);
this.addSelector("draw_rain_particle_range", 242, 0, 240, 0); this.addSelector("draw_rain_particle_range", 242, 0, 240, 0);
this.addSelector("crosshair_size", 0, 20, 240, 0);
this.addSelector("crosshair_color_notarget", 0, 70, 240, 0);
this.addSelector("crosshair_color_target", 242, 70, 240, 0);
super.init(width, height); super.init(width, height);
} }

View file

@ -41,8 +41,7 @@ public class GuiStyle extends GuiOptions implements DropdownCallback<String>, Bu
protected Element addSelector(String cvar, int x, int y, int w, int h) { protected Element addSelector(String cvar, int x, int y, int w, int h) {
CVar cv = this.gm.getVar(cvar); CVar cv = this.gm.getVar(cvar);
if(cv instanceof ColorVar color) { if(cv instanceof ColorVar color) {
if(!color.getDisplay().isEmpty()) this.add(color.label(x, y, w));
this.add(color.label(x, y, w));
if(this.gm.style != Style.CUSTOM) if(this.gm.style != Style.CUSTOM)
return this.add(new Field(x, y, w, h, color.getFieldValue(this.gm.style))); return this.add(new Field(x, y, w, h, color.getFieldValue(this.gm.style)));
else else

View file

@ -46,8 +46,14 @@ public class ColorVar extends IntVar {
public client.gui.element.Field editor(int x, int y, int w, int h) { public client.gui.element.Field editor(int x, int y, int w, int h) {
return new client.gui.element.Field(x, y, w, h, this.alpha ? 8 : 6, new FieldCallback() { return new client.gui.element.Field(x, y, w, h, this.alpha ? 8 : 6, new FieldCallback() {
public void use(client.gui.element.Field elem, FieldAction value) { public void use(client.gui.element.Field elem, FieldAction value) {
if(value == FieldAction.SEND || value == FieldAction.UNFOCUS) if(value == FieldAction.SEND || value == FieldAction.UNFOCUS) {
ColorVar.this.parse(elem.getText()); if(!ColorVar.this.parse(elem.getText()))
elem.setText(ColorVar.this.format());
}
else if(value == FieldAction.FUNCTION) {
ColorVar.this.parse(ColorVar.this.getDefault());
elem.setText(ColorVar.this.format());
}
} }
}, this.format()); }, this.format());
} }