-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new artnet config screen with support for multiple universes
- Loading branch information
Showing
10 changed files
with
454 additions
and
177 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
155 changes: 74 additions & 81 deletions
155
common/src/main/java/dev/imabad/theatrical/client/dmx/TheatricalArtNetClient.java
Large diffs are not rendered by default.
Oops, something went wrong.
225 changes: 147 additions & 78 deletions
225
common/src/main/java/dev/imabad/theatrical/client/gui/screen/ArtNetConfigurationScreen.java
Large diffs are not rendered by default.
Oops, something went wrong.
123 changes: 123 additions & 0 deletions
123
...c/main/java/dev/imabad/theatrical/client/gui/widgets/ArtNetUniverseConfigurationList.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,123 @@ | ||
package dev.imabad.theatrical.client.gui.widgets; | ||
|
||
import dev.imabad.theatrical.client.gui.screen.ArtNetConfigurationScreen; | ||
import dev.imabad.theatrical.config.UniverseConfig; | ||
import net.fabricmc.api.EnvType; | ||
import net.fabricmc.api.Environment; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.Font; | ||
import net.minecraft.client.gui.GuiGraphics; | ||
import net.minecraft.client.gui.components.AbstractWidget; | ||
import net.minecraft.client.gui.components.ObjectSelectionList; | ||
import net.minecraft.client.gui.layouts.LayoutElement; | ||
import net.minecraft.client.gui.screens.packs.PackSelectionScreen; | ||
import net.minecraft.network.chat.Component; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.function.Consumer; | ||
|
||
public class ArtNetUniverseConfigurationList extends ObjectSelectionList<ArtNetUniverseConfigurationList.Entry> implements LayoutElement { | ||
|
||
private ArtNetConfigurationScreen parent; | ||
public ArtNetUniverseConfigurationList(Minecraft minecraft, ArtNetConfigurationScreen screen, int width, int height, Component title) { | ||
super(minecraft, width, height, 32, height - 55 + 4, 30); | ||
this.parent = screen; | ||
this.setRenderBackground(true); | ||
this.setRenderHeader(false, 0); | ||
this.setRenderTopAndBottom(false); | ||
} | ||
|
||
public void setEntries(Map<Integer, UniverseConfig> configs){ | ||
this.clearEntries(); | ||
configs.forEach((key, value) -> addEntry(new Entry(parent, key, value))); | ||
} | ||
|
||
@Override | ||
protected int getScrollbarPosition() { | ||
return this.getX() + this.getRowWidth() + 6; | ||
} | ||
|
||
@Override | ||
public int getRowWidth() { | ||
return width - 10; | ||
} | ||
|
||
@Override | ||
public void setX(int x) { | ||
setLeftPos(x); | ||
} | ||
|
||
@Override | ||
public void setY(int y) { | ||
this.y0 = y; | ||
this.y1 = y + height; | ||
} | ||
|
||
@Override | ||
public int getX() { | ||
return x0; | ||
} | ||
|
||
@Override | ||
public int getY() { | ||
return y0; | ||
} | ||
|
||
@Override | ||
public int getWidth() { | ||
return x1 - x0; | ||
} | ||
|
||
@Override | ||
public int getHeight() { | ||
return height; | ||
} | ||
|
||
@Override | ||
public void visitWidgets(Consumer<AbstractWidget> consumer) { | ||
} | ||
|
||
@Environment(EnvType.CLIENT) | ||
public static class Entry extends ObjectSelectionList.Entry<Entry> implements AutoCloseable { | ||
|
||
private final ArtNetConfigurationScreen parent; | ||
private UniverseConfig config; | ||
private int networkUniverse; | ||
public Entry(ArtNetConfigurationScreen parent, int networkUniverse, UniverseConfig config) { | ||
this.parent = parent; | ||
this.config = config; | ||
this.networkUniverse = networkUniverse; | ||
} | ||
|
||
@Override | ||
public Component getNarration() { | ||
return Component.empty(); | ||
} | ||
|
||
public void close() { | ||
} | ||
|
||
public UniverseConfig getConfig() { | ||
return config; | ||
} | ||
|
||
public int getNetworkUniverse() { | ||
return networkUniverse; | ||
} | ||
|
||
@Override | ||
public void render(GuiGraphics guiGraphics, int index, int top, int left, int width, int height, int mouseX, int mouseY, boolean hovering, float partialTick) { | ||
Font font = Minecraft.getInstance().font; | ||
guiGraphics.drawString(font, Component.translatable("screen.artnetconfig.entry.universe", networkUniverse), left, top + 1, 16777215 ); | ||
// guiGraphics.drawString(font, Component.translatable("screen.artnetconfig.entry.subnet", config.getSubnet()), left, top + 1, 16777215 ); | ||
// guiGraphics.drawString(font, Component.translatable("screen.artnetconfig.entry.universe", config.getUniverse()), left, top + 4 + font.lineHeight, 16777215 ); | ||
} | ||
|
||
@Override | ||
public boolean mouseClicked(double mouseX, double mouseY, int button) { | ||
this.parent.setSelected(this); | ||
return false; | ||
} | ||
} | ||
} |
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
63 changes: 63 additions & 0 deletions
63
common/src/main/java/dev/imabad/theatrical/config/UniverseConfig.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,63 @@ | ||
package dev.imabad.theatrical.config; | ||
|
||
import java.util.Objects; | ||
|
||
public final class UniverseConfig { | ||
|
||
public int subnet; | ||
public int universe; | ||
public boolean enabled; | ||
|
||
public UniverseConfig(){} | ||
|
||
public UniverseConfig(int subnet, int universe, boolean enabled) { | ||
this.subnet = subnet; | ||
this.universe = universe; | ||
this.enabled = enabled; | ||
} | ||
public int getSubnet() { | ||
return subnet; | ||
} | ||
|
||
public int getUniverse() { | ||
return universe; | ||
} | ||
|
||
public void setSubnet(int subnet) { | ||
this.subnet = subnet; | ||
} | ||
|
||
public void setUniverse(int universe) { | ||
this.universe = universe; | ||
} | ||
|
||
public boolean isEnabled() { | ||
return enabled; | ||
} | ||
|
||
public void setEnabled(boolean enabled) { | ||
this.enabled = enabled; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (obj == this) return true; | ||
if (obj == null || obj.getClass() != this.getClass()) return false; | ||
var that = (UniverseConfig) obj; | ||
return this.subnet == that.subnet && | ||
this.universe == that.universe; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(subnet, universe); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "UniverseConfig[" + | ||
"subnet=" + subnet + ", " + | ||
"universe=" + universe + ']'; | ||
} | ||
|
||
} |
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