Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 0 additions & 70 deletions src/main/java/com/cleanroommc/modularui/ClientEventHandler.java

This file was deleted.

1 change: 0 additions & 1 deletion src/main/java/com/cleanroommc/modularui/ClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public class ClientProxy extends CommonProxy {
void preInit(FMLPreInitializationEvent event) {
super.preInit(event);

MinecraftForge.EVENT_BUS.register(ClientEventHandler.class);
MinecraftForge.EVENT_BUS.register(ClientScreenHandler.class);
MinecraftForge.EVENT_BUS.register(OverlayManager.class);
MinecraftForge.EVENT_BUS.register(KeyBindHandler.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.cleanroommc.modularui.screen.ModularPanel;
import com.cleanroommc.modularui.screen.SecondaryPanel;
import com.cleanroommc.modularui.value.sync.ItemSlotSH;
import com.cleanroommc.modularui.value.sync.PanelSyncHandler;
import com.cleanroommc.modularui.value.sync.PanelSyncManager;

Expand Down Expand Up @@ -34,6 +35,8 @@ static IPanelHandler simple(ModularPanel parent, SecondaryPanel.IPanelBuilder pr
return new SecondaryPanel(parent, provider, subPanel);
}

boolean isPanelOpen();

/**
* Opens the panel. If there is no cached panel, one will be created.
* Can be called on both sides if this handler is synced.
Expand All @@ -60,9 +63,9 @@ static IPanelHandler simple(ModularPanel parent, SecondaryPanel.IPanelBuilder pr

/**
* Deletes the current cached panel. Should not be used frequently.
* This only works on non synced panels. Otherwise, it crashes.
* This only works on panels which don't have {@link ItemSlotSH} sync handlers.
*
* @throws UnsupportedOperationException if this handler is synced
* @throws UnsupportedOperationException if this handler has ItemSlot sync handlers
*/
void deleteCachedPanel();

Expand Down
22 changes: 0 additions & 22 deletions src/main/java/com/cleanroommc/modularui/api/IPanelSyncManager.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ static IKey comp(@NotNull IKey... keys) {
* @param getter string supplier
* @return dynamic text key
*/
static IKey dynamic(@NotNull Supplier<String> getter) {
static IKey dynamic(@NotNull Supplier<@NotNull String> getter) {
return new DynamicKey(getter);
}

Expand Down Expand Up @@ -181,15 +181,15 @@ default StyledText alignment(Alignment alignment) {
return withStyle().alignment(alignment);
}

default StyledText color(int color) {
default StyledText color(@Nullable Integer color) {
return withStyle().color(color);
}

default StyledText scale(float scale) {
return withStyle().scale(scale);
}

default StyledText shadow(boolean shadow) {
default StyledText shadow(@Nullable Boolean shadow) {
return withStyle().shadow(shadow);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import org.jetbrains.annotations.Nullable;

public class AnimatedText extends StyledText {

private String fullString;
Expand Down Expand Up @@ -111,7 +113,7 @@ public AnimatedText alignment(Alignment alignment) {
}

@Override
public AnimatedText color(int color) {
public AnimatedText color(@Nullable Integer color) {
return (AnimatedText) super.color(color);
}

Expand All @@ -121,7 +123,7 @@ public AnimatedText scale(float scale) {
}

@Override
public AnimatedText shadow(boolean shadow) {
public AnimatedText shadow(@Nullable Boolean shadow) {
return (AnimatedText) super.shadow(shadow);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.cleanroommc.modularui.drawable.text;

import com.cleanroommc.modularui.ClientEventHandler;
import com.cleanroommc.modularui.api.drawable.IKey;
import com.cleanroommc.modularui.screen.ClientScreenHandler;

public class CompoundKey extends BaseKey {

Expand All @@ -17,8 +17,8 @@ public CompoundKey(IKey... keys) {

@Override
public String get() {
if (ClientEventHandler.getTicks() != this.time) {
this.time = ClientEventHandler.getTicks();
if (ClientScreenHandler.getTicks() != this.time) {
this.time = ClientScreenHandler.getTicks();
StringBuilder builder = new StringBuilder();
for (IKey key : this.keys) {
builder.append(key.get());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.cleanroommc.modularui.drawable.text;

import java.util.Objects;
import java.util.function.Supplier;

public class DynamicKey extends BaseKey {

private final Supplier<String> supplier;

public DynamicKey(Supplier<String> supplier) {
Objects.requireNonNull(supplier.get(), "IKey returns a null string!");
this.supplier = supplier;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.cleanroommc.modularui.drawable.text;

import com.cleanroommc.modularui.ClientEventHandler;
import com.cleanroommc.modularui.screen.ClientScreenHandler;

import net.minecraft.client.resources.I18n;

Expand Down Expand Up @@ -48,10 +48,10 @@ public Supplier<Object[]> getArgsSupplier() {

@Override
public String get() {
if (this.time == ClientEventHandler.getTicks()) {
if (this.time == ClientScreenHandler.getTicks()) {
return this.string;
}
this.time = ClientEventHandler.getTicks();
this.time = ClientScreenHandler.getTicks();
this.string = I18n.format(Objects.requireNonNull(this.keySupplier.get()), this.argsSupplier.get()).replaceAll("\\\\n", "\n");
return string;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import org.jetbrains.annotations.Nullable;

public class StyledText extends BaseKey {

private final IKey key;
Expand Down Expand Up @@ -72,7 +74,7 @@ public StyledText alignment(Alignment alignment) {
}

@Override
public StyledText color(int color) {
public StyledText color(@Nullable Integer color) {
this.color = color;
return this;
}
Expand All @@ -84,7 +86,7 @@ public StyledText scale(float scale) {
}

@Override
public StyledText shadow(boolean shadow) {
public StyledText shadow(@Nullable Boolean shadow) {
this.shadow = shadow;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import org.jetbrains.annotations.Nullable;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;

import java.awt.*;
import java.io.IOException;
Expand All @@ -65,6 +66,7 @@ public class ClientScreenHandler {
private static ModularScreen currentScreen = null;
private static Character lastChar = null;
private static final FpsCounter fpsCounter = new FpsCounter();
private static long ticks = 0L;

@SubscribeEvent
public static void onGuiOpen(GuiOpenEvent event) {
Expand Down Expand Up @@ -148,9 +150,22 @@ public static void onTick(TickEvent.ClientTickEvent event) {
if (checkGui()) {
currentScreen.onUpdate();
}
ticks++;
}
}

@SubscribeEvent
public static void preDraw(TickEvent.RenderTickEvent event) {
if (event.phase == TickEvent.Phase.START) {
GL11.glEnable(GL11.GL_STENCIL_TEST);
}
Stencil.reset();
}

public static long getTicks() {
return ticks;
}

public static void onFrameUpdate() {
OverlayStack.foreach(ModularScreen::onFrameUpdate, true);
if (currentScreen != null) currentScreen.onFrameUpdate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -624,9 +624,13 @@ public final boolean isMainPanel() {
}

@ApiStatus.Internal
public void setSyncHandler(@Nullable PanelSyncHandler syncHandler) {
@Override
public void setSyncHandler(@Nullable SyncHandler syncHandler) {
if (!isValidSyncHandler(syncHandler))
throw new IllegalStateException("Panel SyncHandler's must implement IPanelHandler!");

super.setSyncHandler(syncHandler);
setPanelHandler(syncHandler);
setPanelHandler((IPanelHandler) syncHandler);
}

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ public boolean isSubPanel() {
return subPanel;
}

@Override
public boolean isPanelOpen() {
return this.open;
}

@Override
public void openPanel() {
if (this.open) return;
Expand Down
Loading