-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[+] KeyBindsHud, Fixed some left over bugs of HudElement. Fixed HudCa…
…tegoryPane not loading from the config, and Copy-Paste of properties of hud elements.
- Loading branch information
1 parent
d28ee08
commit b21169f
Showing
12 changed files
with
101 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/main/java/dev/heliosclient/hud/hudelements/KeyBindsHud.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package dev.heliosclient.hud.hudelements; | ||
|
||
import dev.heliosclient.hud.HudElement; | ||
import dev.heliosclient.hud.HudElementData; | ||
import dev.heliosclient.managers.ColorManager; | ||
import dev.heliosclient.managers.ModuleManager; | ||
import dev.heliosclient.module.Module_; | ||
import dev.heliosclient.module.settings.KeyBind; | ||
import dev.heliosclient.util.ColorUtils; | ||
import dev.heliosclient.util.KeyboardUtils; | ||
import dev.heliosclient.util.render.Renderer2D; | ||
import net.minecraft.client.font.TextRenderer; | ||
import net.minecraft.client.gui.DrawContext; | ||
|
||
public class KeyBindsHud extends HudElement { | ||
public static HudElementData<KeyBindsHud> DATA = new HudElementData<>("KeybindsHUD", "Shows the modules with keybinds", KeyBindsHud::new); | ||
|
||
public KeyBindsHud() { | ||
super(DATA); | ||
this.width = 50; | ||
this.height = Math.round(Renderer2D.getStringHeight()); | ||
} | ||
|
||
@Override | ||
public void renderElement(DrawContext drawContext, TextRenderer textRenderer) { | ||
super.renderElement(drawContext, textRenderer); | ||
|
||
int width = 20, height = 0; | ||
int y = this.y + 1; | ||
for(Module_ module : ModuleManager.getModules()){ | ||
if(module.keyBind.value == KeyBind.none()) continue; | ||
|
||
String text = module.name + (module.isActive()? ColorUtils.green : ColorUtils.darkRed) + " [" + KeyboardUtils.translateShort(module.keyBind.value) + "]"; | ||
|
||
width = Math.round(Math.max(width, Renderer2D.getStringWidth(text) + 5)); | ||
|
||
Renderer2D.drawString(drawContext.getMatrices(),text,x + 2,y, ColorManager.INSTANCE.hudColor); | ||
|
||
y += (int) (Renderer2D.getStringHeight(text) + 3); | ||
height += Math.round(Renderer2D.getStringHeight(text)) + 3; | ||
} | ||
|
||
this.width = width; | ||
this.height = Math.max(10, height + 1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters