-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5eb7f20
commit c31796b
Showing
19 changed files
with
190 additions
and
175 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 was deleted.
Oops, something went wrong.
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,21 @@ | ||
package ua.mei.mgui.api.gui; | ||
|
||
import net.minecraft.screen.GenericContainerScreenHandler; | ||
import net.minecraft.screen.ScreenHandlerType; | ||
|
||
import java.util.List; | ||
|
||
public class MGuiHelpers { | ||
private static final List<ScreenHandlerType<GenericContainerScreenHandler>> genericScreenHandlers = List.of( | ||
ScreenHandlerType.GENERIC_9X1, | ||
ScreenHandlerType.GENERIC_9X2, | ||
ScreenHandlerType.GENERIC_9X3, | ||
ScreenHandlerType.GENERIC_9X4, | ||
ScreenHandlerType.GENERIC_9X5, | ||
ScreenHandlerType.GENERIC_9X6 | ||
); | ||
|
||
public static boolean isGeneric(ScreenHandlerType<?> screenHandlerType) { | ||
return genericScreenHandlers.contains(screenHandlerType); | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
src/main/java/ua/mei/mgui/api/gui/element/GlyphElement.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,27 @@ | ||
package ua.mei.mgui.api.gui.element; | ||
|
||
import net.minecraft.text.Text; | ||
import ua.mei.pfu.api.BitmapGlyph; | ||
import ua.mei.pfu.api.FontResource; | ||
|
||
public class GlyphElement extends MGuiElement { | ||
public final BitmapGlyph glyph; | ||
|
||
public GlyphElement(BitmapGlyph glyph) { | ||
this.glyph = glyph; | ||
} | ||
|
||
public GlyphElement(String path, int height, int y, FontResource resource) { | ||
this(resource.requestGlyph(path, height, y + 13)); | ||
} | ||
|
||
@Override | ||
public Text render() { | ||
return this.glyph.value; | ||
} | ||
|
||
@Override | ||
public int getWidth() { | ||
return this.glyph.glyphWidth; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
33 changes: 15 additions & 18 deletions
33
src/main/java/ua/mei/mgui/api/gui/element/VanillaElements.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 |
---|---|---|
@@ -1,41 +1,38 @@ | ||
package ua.mei.mgui.api.gui.element; | ||
|
||
import net.minecraft.screen.ScreenHandlerType; | ||
import net.minecraft.text.Text; | ||
import org.jetbrains.annotations.ApiStatus; | ||
import org.jetbrains.annotations.Nullable; | ||
import ua.mei.mgui.impl.MGuiImpl; | ||
import ua.mei.pfu.api.FontResource; | ||
|
||
@ApiStatus.Internal | ||
public class VanillaElements { | ||
private static final FontResource resource = MGuiImpl.manager.requestFont("gui/vanilla"); | ||
|
||
public static final GuiElement GENERIC_9X1 = Elements.texture("gui/container/generic_9x1.png", 256, 0, resource); | ||
public static final GuiElement GENERIC_9X2 = Elements.texture("gui/container/generic_9x2.png", 256, 0, resource); | ||
public static final GuiElement GENERIC_9X3 = Elements.texture("gui/container/generic_9x3.png", 256, 0, resource); | ||
public static final GuiElement GENERIC_9X4 = Elements.texture("gui/container/generic_9x4.png", 256, 0, resource); | ||
public static final GuiElement GENERIC_9X5 = Elements.texture("gui/container/generic_9x5.png", 256, 0, resource); | ||
public static final GuiElement GENERIC_9X6 = Elements.texture("gui/container/generic_9x6.png", 256, 0, resource); | ||
public static final MGuiElement GENERIC_9X1 = new GlyphElement("gui/container/generic_9x1.png", 256, 0, resource); | ||
public static final MGuiElement GENERIC_9X2 = new GlyphElement("gui/container/generic_9x2.png", 256, 0, resource); | ||
public static final MGuiElement GENERIC_9X3 = new GlyphElement("gui/container/generic_9x3.png", 256, 0, resource); | ||
public static final MGuiElement GENERIC_9X4 = new GlyphElement("gui/container/generic_9x4.png", 256, 0, resource); | ||
public static final MGuiElement GENERIC_9X5 = new GlyphElement("gui/container/generic_9x5.png", 256, 0, resource); | ||
public static final MGuiElement GENERIC_9X6 = new GlyphElement("gui/container/generic_9x6.png", 256, 0, resource); | ||
|
||
public static void load() { | ||
|
||
} | ||
|
||
public static Text fromScreenHandler(ScreenHandlerType<?> handler) { | ||
public static @Nullable MGuiElement fromScreenHandler(ScreenHandlerType<?> handler) { | ||
if (handler == ScreenHandlerType.GENERIC_9X1) { | ||
return GENERIC_9X1.render(); | ||
return GENERIC_9X1; | ||
} else if (handler == ScreenHandlerType.GENERIC_9X2) { | ||
return GENERIC_9X2.render(); | ||
return GENERIC_9X2; | ||
} else if (handler == ScreenHandlerType.GENERIC_9X3) { | ||
return GENERIC_9X3.render(); | ||
return GENERIC_9X3; | ||
} else if (handler == ScreenHandlerType.GENERIC_9X4) { | ||
return GENERIC_9X4.render(); | ||
return GENERIC_9X4; | ||
} else if (handler == ScreenHandlerType.GENERIC_9X5) { | ||
return GENERIC_9X5.render(); | ||
return GENERIC_9X5; | ||
} else if (handler == ScreenHandlerType.GENERIC_9X6) { | ||
return GENERIC_9X6.render(); | ||
return GENERIC_9X6; | ||
} else { | ||
return Text.empty(); | ||
return null; | ||
} | ||
} | ||
} |
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,58 @@ | ||
package ua.mei.mgui.impl; | ||
|
||
import net.minecraft.text.MutableText; | ||
import net.minecraft.text.Text; | ||
import net.minecraft.util.Formatting; | ||
import org.jetbrains.annotations.ApiStatus; | ||
import ua.mei.mgui.api.gui.TexturedGui; | ||
import ua.mei.mgui.api.gui.element.MGuiElement; | ||
import ua.mei.pfu.api.util.TextBuilder; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@ApiStatus.Internal | ||
public class MGuiDrawContext { | ||
private final List<Object> elements = new ArrayList<>(); | ||
private int x = 0; | ||
|
||
public MGuiDrawContext() { | ||
} | ||
|
||
public void x(int x) { | ||
this.x = x; | ||
} | ||
|
||
public void draw(MGuiElement element) { | ||
if (!this.elements.isEmpty() && this.elements.getLast() instanceof Integer space) { | ||
this.elements.set(this.elements.size() - 1, space + this.x); | ||
} else { | ||
this.elements.add(this.x - 8); | ||
} | ||
this.elements.add(element); | ||
this.elements.add(-element.getWidth() - this.x - 1); | ||
} | ||
|
||
public Text render(TexturedGui gui) { | ||
TextBuilder builder = new TextBuilder(); | ||
|
||
if (gui.customTitle == null && !this.elements.isEmpty()) { | ||
this.elements.removeLast(); | ||
} | ||
|
||
this.elements.forEach(obj -> { | ||
if (obj instanceof Integer space && space != 0) { | ||
builder.space(space); | ||
} else if (obj instanceof MGuiElement element) { | ||
builder.text(((MutableText) element.render()).formatted(Formatting.WHITE)); | ||
} | ||
}); | ||
|
||
if (gui.customTitle != null) { | ||
builder.space(8); | ||
builder.text(gui.customTitle); | ||
} | ||
|
||
return builder.build(); | ||
} | ||
} |
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
20 changes: 0 additions & 20 deletions
20
src/main/java/ua/mei/mgui/impl/packet/MGuiOpenScreenPacket.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.