Skip to content

Commit

Permalink
start making a Zeta resources dir so I can move the rest of the confi…
Browse files Browse the repository at this point in the history
…g gui code
  • Loading branch information
quat1024 committed Oct 26, 2023
1 parent 510478a commit d39b675
Show file tree
Hide file tree
Showing 28 changed files with 138 additions and 98 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package vazkii.quark.base.client.config.widget;
package vazkii.quark.base.client.config;

import java.awt.*;
import java.io.File;
Expand All @@ -19,8 +19,7 @@
import net.minecraft.client.resources.language.I18n;
import net.minecraft.network.chat.Component;
import vazkii.quark.base.QuarkClient;
import vazkii.quark.base.client.config.screen.QuarkConfigHomeScreen;
import vazkii.quark.base.client.handler.TopLayerTooltipHandler;
import vazkii.zeta.client.TopLayerTooltipHandler;
import vazkii.quark.base.handler.ContributorRewardHandler;
import vazkii.quark.base.handler.GeneralConfig;
import vazkii.quark.base.handler.MiscUtil;
Expand Down Expand Up @@ -144,7 +143,7 @@ public void renderButton(@Nonnull PoseStack mstack, int mouseX, int mouseY, floa

boolean hovered = mouseX >= x && mouseY >= y && mouseX < (x + width) && mouseY < (y + height);
if(hovered)
TopLayerTooltipHandler.setTooltip(List.of(I18n.get("quark.gui.celebration." + celebrating.name)), mouseX, mouseY);
QuarkClient.ZETA_CLIENT.topLayerTooltipHandler.setTooltip(List.of(I18n.get("quark.gui.celebration." + celebrating.name)), mouseX, mouseY);
}

int u = 256 - iconIndex * w;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import net.minecraft.client.resources.language.I18n;
import net.minecraftforge.client.event.ScreenEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import vazkii.quark.base.client.config.widget.QButton;
import vazkii.quark.base.handler.GeneralConfig;

public class QButtonHandler {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package vazkii.quark.base.client.config.screen;
package vazkii.quark.base.client.config;

import java.util.Iterator;
import java.util.List;
Expand All @@ -16,7 +16,6 @@
import net.minecraft.resources.ResourceLocation;
import vazkii.quark.base.Quark;
import vazkii.quark.base.QuarkClient;
import vazkii.quark.base.client.config.widget.SocialButton;
import vazkii.quark.base.handler.ContributorRewardHandler;
import vazkii.quark.base.handler.GeneralConfig;
import vazkii.zeta.client.config.screen.ZetaConfigHomeScreen;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package vazkii.quark.base.client.config.widget;
package vazkii.quark.base.client.config;

import java.util.List;

Expand All @@ -12,7 +12,8 @@
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import vazkii.quark.base.Quark;
import vazkii.quark.base.client.handler.TopLayerTooltipHandler;
import vazkii.quark.base.QuarkClient;
import vazkii.zeta.client.TopLayerTooltipHandler;

public class SocialButton extends Button {

Expand Down Expand Up @@ -49,7 +50,7 @@ public void renderButton(@Nonnull PoseStack mstack, int mouseX, int mouseY, floa
blit(mstack, x, y, u, v, 20, 20, 128, 64);

if(isHovered)
TopLayerTooltipHandler.setTooltip(List.of(text.getString()), mouseX, mouseY);
QuarkClient.ZETA_CLIENT.topLayerTooltipHandler.setTooltip(List.of(text.getString()), mouseX, mouseY);
}

@Override
Expand Down

This file was deleted.

4 changes: 2 additions & 2 deletions src/main/java/vazkii/quark/base/proxy/ClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
import vazkii.quark.base.Quark;
import vazkii.quark.base.QuarkClient;
import vazkii.quark.base.client.config.QButtonHandler;
import vazkii.quark.base.client.config.screen.QuarkConfigHomeScreen;
import vazkii.quark.base.client.config.QuarkConfigHomeScreen;
import vazkii.quark.base.client.handler.InventoryButtonHandler;
import vazkii.quark.base.client.handler.ModelHandler;
import vazkii.quark.base.client.handler.NetworkProfilingHandler;
import vazkii.quark.base.client.handler.RequiredModTooltipHandler;
import vazkii.quark.base.client.handler.TopLayerTooltipHandler;
import vazkii.zeta.client.TopLayerTooltipHandler;
import vazkii.quark.base.handler.ContributorRewardHandler;
import vazkii.quark.base.handler.DyeHandler;
import vazkii.quark.base.handler.MiscUtil;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
import net.minecraftforge.client.event.ScreenEvent.MouseButtonPressed;
import net.minecraftforge.event.TickEvent.ClientTickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import vazkii.quark.base.client.handler.TopLayerTooltipHandler;
import vazkii.quark.base.QuarkClient;
import vazkii.zeta.client.TopLayerTooltipHandler;
import vazkii.quark.base.handler.MiscUtil;
import vazkii.quark.base.module.LoadModule;
import vazkii.zeta.module.ZetaModule;
Expand Down Expand Up @@ -165,7 +166,7 @@ public void onDrawGui(ContainerScreenEvent.Render.Background event) {
if(pair != null) {
GhostIngredient ingr = pair.getRight();
if(ingr != null)
TopLayerTooltipHandler.setTooltip(Lists.newArrayList(I18n.get("quark.misc.rightclick_to_craft")), event.getMouseX(), event.getMouseY() - 15);
QuarkClient.ZETA_CLIENT.topLayerTooltipHandler.setTooltip(Lists.newArrayList(I18n.get("quark.misc.rightclick_to_craft")), event.getMouseX(), event.getMouseY() - 15);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
import net.minecraft.client.resources.language.I18n;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import vazkii.quark.base.client.handler.TopLayerTooltipHandler;
import vazkii.quark.base.QuarkClient;
import vazkii.zeta.client.TopLayerTooltipHandler;
import vazkii.quark.base.handler.MiscUtil;

public class MiniInventoryButton extends Button {
Expand Down Expand Up @@ -73,7 +74,7 @@ public void renderButton(@Nonnull PoseStack matrix, int mouseX, int mouseY, floa
blit(matrix, x, y, u, v, width, height);

if(isHovered)
TopLayerTooltipHandler.setTooltip(getTooltip(), mouseX, mouseY);
QuarkClient.ZETA_CLIENT.topLayerTooltipHandler.setTooltip(getTooltip(), mouseX, mouseY);
}

@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import vazkii.zeta.event.ZRegister;
import vazkii.zeta.event.bus.LoadEvent;
import vazkii.zeta.event.bus.PlayEvent;
import vazkii.zeta.client.event.ZEndClientTickEvent;
import vazkii.zeta.client.event.ZEndClientTick;
import vazkii.zeta.module.ZetaLoadModule;
import vazkii.zeta.module.ZetaModule;

Expand Down Expand Up @@ -58,7 +58,7 @@ public static class Client extends EndermoshMusicDiscModule {
private SimpleSoundInstance sound;

@PlayEvent
public void tick(ZEndClientTickEvent event) {
public void tick(ZEndClientTick event) {
if(playEndermoshDuringEnderdragonFight) {
boolean wasFightingDragon = isFightingDragon;

Expand Down
40 changes: 40 additions & 0 deletions src/main/java/vazkii/zeta/client/TopLayerTooltipHandler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package vazkii.zeta.client;

import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

import com.mojang.blaze3d.vertex.PoseStack;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack;
import vazkii.zeta.client.event.ZEndRenderTick;
import vazkii.zeta.event.bus.PlayEvent;

public class TopLayerTooltipHandler {

private List<Component> tooltip;
private int tooltipX, tooltipY;

@PlayEvent
public void endRenderTick(ZEndRenderTick event) {
if(tooltip != null) {
Minecraft mc = Minecraft.getInstance();
Screen screen = Minecraft.getInstance().screen;

//TODO: I think this is a Forge extension
screen.renderTooltip(new PoseStack(), tooltip, Optional.empty(), tooltipX, tooltipY, mc.font, ItemStack.EMPTY);

tooltip = null;
}
}

public void setTooltip(List<String> tooltip, int x, int y) {
this.tooltip = tooltip.stream().map(Component::literal).collect(Collectors.toList());
this.tooltipX = x;
this.tooltipY = y;
}

}
7 changes: 7 additions & 0 deletions src/main/java/vazkii/zeta/client/ZetaClient.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package vazkii.zeta.client;

import net.minecraft.resources.ResourceLocation;
import vazkii.zeta.Zeta;
import vazkii.zeta.client.config.ClientConfigManager;
import vazkii.zeta.event.bus.IZetaLoadEvent;
Expand All @@ -15,14 +16,20 @@ public ZetaClient(Zeta zeta) {
//this.ticker = new ClientTicker();
this.ticker = zeta.ticker_SHOULD_NOT_BE_HERE; //TODO, move ClientTicker into actual client code
this.clientConfigManager = new ClientConfigManager();
this.topLayerTooltipHandler = new TopLayerTooltipHandler();

playBus.subscribe(topLayerTooltipHandler);
}

public final Zeta zeta;
protected final ZetaEventBus<IZetaLoadEvent> loadBus;
protected final ZetaEventBus<IZetaPlayEvent> playBus;

public ResourceLocation generalIcons = new ResourceLocation("zeta", "textures/gui/general_icons.png");

public final ClientTicker ticker;
public final ClientConfigManager clientConfigManager;
public final TopLayerTooltipHandler topLayerTooltipHandler;

public abstract void start();
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.client.gui.screens.Screen;
import vazkii.quark.base.client.config.widget.CheckboxButton;
import vazkii.zeta.client.config.widget.CheckboxButton;
import vazkii.zeta.client.ZetaClient;
import vazkii.zeta.config.ChangeSet;
import vazkii.zeta.config.ValueDefinition;
Expand All @@ -17,6 +17,6 @@ public String getSubtitle(ChangeSet changes, ValueDefinition<Boolean> def) {

@Override
public void addWidgets(ZetaClient zc, Screen parent, ChangeSet changes, ValueDefinition<Boolean> def, Consumer<AbstractWidget> widgets) {
widgets.accept(new CheckboxButton(230, 3, changes, def));
widgets.accept(new CheckboxButton(zc, 230, 3, changes, def));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import net.minecraft.world.item.Items;
import net.minecraftforge.client.gui.widget.ForgeSlider;
import vazkii.zeta.client.config.screen.AbstractSectionInputScreen;
import vazkii.quark.base.client.config.widget.PencilButton;
import vazkii.zeta.client.config.widget.PencilButton;
import vazkii.quark.base.module.config.type.inputtable.ConvulsionMatrixConfig;
import vazkii.zeta.client.ZetaClient;
import vazkii.zeta.config.ChangeSet;
Expand Down Expand Up @@ -62,7 +62,7 @@ public String getSubtitle(ChangeSet changes, SectionDefinition def) {
@Override
public void addWidgets(ZetaClient zc, Screen parent, ChangeSet changes, SectionDefinition def, Consumer<AbstractWidget> widgets) {
Screen newScreen = new ConvulsionMatrixInputScreen(zc, parent, changes, def);
widgets.accept(new PencilButton(230, 3, b1 -> Minecraft.getInstance().setScreen(newScreen)));
widgets.accept(new PencilButton(zc, 230, 3, b1 -> Minecraft.getInstance().setScreen(newScreen)));
}

class ConvulsionMatrixInputScreen extends AbstractSectionInputScreen {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import net.minecraft.client.gui.screens.Screen;
import org.jetbrains.annotations.Nullable;
import vazkii.zeta.client.config.screen.AbstractEditBoxInputScreen;
import vazkii.quark.base.client.config.widget.PencilButton;
import vazkii.zeta.client.config.widget.PencilButton;
import vazkii.zeta.client.ZetaClient;
import vazkii.zeta.config.ChangeSet;
import vazkii.zeta.config.ValueDefinition;
Expand Down Expand Up @@ -35,6 +35,6 @@ protected int maxStringLength() {
}
}
};
widgets.accept(new PencilButton(230, 3, b -> Minecraft.getInstance().setScreen(newScreen)));
widgets.accept(new PencilButton(zc, 230, 3, b -> Minecraft.getInstance().setScreen(newScreen)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import net.minecraft.client.gui.screens.Screen;
import org.jetbrains.annotations.Nullable;
import vazkii.zeta.client.config.screen.AbstractEditBoxInputScreen;
import vazkii.quark.base.client.config.widget.PencilButton;
import vazkii.zeta.client.config.widget.PencilButton;
import vazkii.zeta.client.ZetaClient;
import vazkii.zeta.config.ChangeSet;
import vazkii.zeta.config.ValueDefinition;
Expand All @@ -30,6 +30,6 @@ public void addWidgets(ZetaClient zc, Screen parent, ChangeSet changes, ValueDef
}
}
};
widgets.accept(new PencilButton(230, 3, b -> Minecraft.getInstance().setScreen(newScreen)));
widgets.accept(new PencilButton(zc, 230, 3, b -> Minecraft.getInstance().setScreen(newScreen)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import net.minecraftforge.client.gui.widget.ForgeSlider;
import org.jetbrains.annotations.Nullable;
import vazkii.zeta.client.config.screen.AbstractSectionInputScreen;
import vazkii.quark.base.client.config.widget.PencilButton;
import vazkii.zeta.client.config.widget.PencilButton;
import vazkii.quark.base.module.config.type.inputtable.RGBAColorConfig;
import vazkii.zeta.client.ZetaClient;
import vazkii.zeta.config.ChangeSet;
Expand Down Expand Up @@ -55,7 +55,7 @@ public String getSubtitle(ChangeSet changes, SectionDefinition def) {
@Override
public void addWidgets(ZetaClient zc, Screen parent, ChangeSet changes, SectionDefinition def, Consumer<AbstractWidget> widgets) {
Screen newScreen = new RGBInputScreen(zc, parent, changes, def);
widgets.accept(new PencilButton(230, 3, b1 -> Minecraft.getInstance().setScreen(newScreen)));
widgets.accept(new PencilButton(zc, 230, 3, b1 -> Minecraft.getInstance().setScreen(newScreen)));
}

class RGBInputScreen extends AbstractSectionInputScreen {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.resources.language.I18n;
import vazkii.zeta.client.config.screen.SectionScreen;
import vazkii.quark.base.client.config.widget.PencilButton;
import vazkii.zeta.client.config.widget.PencilButton;
import vazkii.zeta.client.ZetaClient;
import vazkii.zeta.config.ChangeSet;
import vazkii.zeta.config.SectionDefinition;
Expand All @@ -22,6 +22,6 @@ public String getSubtitle(ChangeSet changes, SectionDefinition def) {

@Override
public void addWidgets(ZetaClient zc, Screen parent, ChangeSet changes, SectionDefinition def, Consumer<AbstractWidget> widgets) {
widgets.accept(new PencilButton(230, 3, b -> Minecraft.getInstance().setScreen(new SectionScreen(zc, parent, changes, def))));
widgets.accept(new PencilButton(zc, 230, 3, b -> Minecraft.getInstance().setScreen(new SectionScreen(zc, parent, changes, def))));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import net.minecraft.client.gui.screens.Screen;
import org.jetbrains.annotations.Nullable;
import vazkii.zeta.client.config.screen.AbstractEditBoxInputScreen;
import vazkii.quark.base.client.config.widget.PencilButton;
import vazkii.zeta.client.config.widget.PencilButton;
import vazkii.zeta.client.ZetaClient;
import vazkii.zeta.config.ChangeSet;
import vazkii.zeta.config.ValueDefinition;
Expand All @@ -26,6 +26,6 @@ public void addWidgets(ZetaClient zc, Screen parent, ChangeSet changes, ValueDef
return string;
}
};
widgets.accept(new PencilButton(230, 3, b -> Minecraft.getInstance().setScreen(newScreen)));
widgets.accept(new PencilButton(zc, 230, 3, b -> Minecraft.getInstance().setScreen(newScreen)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.client.gui.screens.Screen;
import vazkii.zeta.client.config.screen.StringListInputScreen;
import vazkii.quark.base.client.config.widget.PencilButton;
import vazkii.zeta.client.config.widget.PencilButton;
import vazkii.zeta.client.ZetaClient;
import vazkii.zeta.config.ChangeSet;
import vazkii.zeta.config.ValueDefinition;
Expand All @@ -33,6 +33,6 @@ public String getSubtitle(ChangeSet changes, ValueDefinition<List<String>> def)
@Override
public void addWidgets(ZetaClient zc, Screen parent, ChangeSet changes, ValueDefinition<List<String>> def, Consumer<AbstractWidget> widgets) {
Screen newScreen = new StringListInputScreen(zc, parent, changes, def);
widgets.accept(new PencilButton(230, 3, b -> Minecraft.getInstance().setScreen(newScreen)));
widgets.accept(new PencilButton(zc, 230, 3, b -> Minecraft.getInstance().setScreen(newScreen)));
}
}
Loading

0 comments on commit d39b675

Please sign in to comment.