Skip to content

Commit

Permalink
color interval info button
Browse files Browse the repository at this point in the history
  • Loading branch information
Goby56 committed Dec 31, 2024
1 parent 1a21f6f commit 7f14a41
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public ColorIntervalSlider(ColorPickerScreen screenContext, int x, int y, int wi
}
this.colorPicker = new ColorPicker(screenContext, 10, screenContext.height / 2 - 64, 128, 128);
colorPicker.registerListener(this::onColorPicked);
this.setTooltip(Tooltip.of(WakesUtils.translatable("gui", "colorIntervalSlider", "tooltip")));
}

private void unfocusHandles() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/goby56/wakes/config/gui/ColorPicker.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

public class ColorPicker extends ClickableWidget {
private static final Identifier FRAME_TEXTURE = Identifier.ofVanilla("widget/slot_frame");
private static final Identifier PICKER_KNOB_TEXTURE = Identifier.of("wakes", "textures/picker_knob.png");
private static final Identifier PICKER_KNOB_TEXTURE = Identifier.of(WakesClient.MOD_ID, "textures/picker_knob.png");
private static final int pickerKnobDim = 7;

private final Map<String, Bounded> widgets = new HashMap<>();
Expand Down
22 changes: 20 additions & 2 deletions src/main/java/com/goby56/wakes/config/gui/ColorPickerScreen.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
package com.goby56.wakes.config.gui;

import com.goby56.wakes.WakesClient;
import com.goby56.wakes.utils.WakesUtils;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.GameModeSelectionScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ClickableWidget;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.client.gui.tooltip.TooltipBackgroundRenderer;
import net.minecraft.client.gui.widget.*;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;

public class ColorPickerScreen extends Screen {
private final Screen parent;
private boolean showInfoText = false;
public ColorPickerScreen(Screen parent) {
super(Text.of("Configure wake colors"));
this.parent = parent;
Expand All @@ -20,6 +24,15 @@ protected void init() {
this,
(int) (width / 2 - width * 0.8f / 2), 24,
(int) (width * 0.8f), 40));
TextIconButtonWidget infoButton = TextIconButtonWidget.builder(Text.empty(), this::onInfoClick, true)
.texture(Identifier.ofVanilla("icon/info"), 20, 20)
.dimension(30, 30).build();
infoButton.setPosition((int) (width / 2 - width * 0.8f / 2 - 35), 29);
this.addDrawableChild(infoButton);
}

private void onInfoClick(ButtonWidget button) {
this.showInfoText = !this.showInfoText;
}

@Override
Expand All @@ -31,6 +44,11 @@ public void close() {
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
super.render(context, mouseX, mouseY, delta);
context.drawCenteredTextWithShadow(textRenderer, WakesUtils.translatable("gui", "colorIntervalSlider", "title"), width / 2, 10, 0xffffff);
if (this.showInfoText) {
// TODO DYNAMIC TOOLTIP BACKGROUND SIZE
TooltipBackgroundRenderer.render(context, width - 350, height - 60, 325, 34, 0);
context.drawTextWrapped(textRenderer, WakesUtils.translatable("gui", "colorIntervalSlider", "info"), width - 350, height - 60, 325, 0xa8a8a8);
}
}

@Override
Expand Down
6 changes: 5 additions & 1 deletion src/main/resources/assets/wakes/lang/en_us.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ wakes:
title: Wakes config
colorIntervalSlider:
title: Color Interval Slider
tooltip: '[SHIFT + Left Click] Adds a separator if the cursor is above an empty spot and removes if hovering over existing separator.'
info: |
- [Left Click] on a section to edit its color
- [Left Drag] a separator to change the extend of that section
- [Shift + Left Click] on a section to insert a new separator
- [Shift + Left Click] on a separator to remove it
configButton: Mod configurations
colorConfigButton: Configure wake colors
midnightconfig:
Expand Down

0 comments on commit 7f14a41

Please sign in to comment.