start of modmenu config screen
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
package com.kasetoatz.fastghast;
|
||||
|
||||
import com.kasetoatz.fastghast.configscreen.ConfigScreen;
|
||||
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
|
||||
import com.terraformersmc.modmenu.api.ModMenuApi;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
|
||||
import net.minecraft.entity.Leashable;
|
||||
@@ -10,7 +13,7 @@ import java.util.EnumSet;
|
||||
|
||||
import static com.kasetoatz.fastghast.config.Config.load;
|
||||
|
||||
public class Fastghast implements ModInitializer
|
||||
public class Fastghast implements ModInitializer, ModMenuApi
|
||||
{
|
||||
@Override
|
||||
public void onInitialize()
|
||||
@@ -23,4 +26,10 @@ public class Fastghast implements ModInitializer
|
||||
}
|
||||
})));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigScreenFactory<?> getModConfigScreenFactory()
|
||||
{
|
||||
return ConfigScreen::new;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.kasetoatz.fastghast.configscreen;
|
||||
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.client.gui.widget.ThreePartsLayoutWidget;
|
||||
import net.minecraft.screen.ScreenTexts;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
public class ConfigScreen extends Screen
|
||||
{
|
||||
private final Screen parent;
|
||||
private final ThreePartsLayoutWidget layout = new ThreePartsLayoutWidget(this);
|
||||
private OptionList body;
|
||||
|
||||
public ConfigScreen(Screen parent)
|
||||
{
|
||||
super(Text.of("TEST SCREEN"));
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init()
|
||||
{
|
||||
this.layout.addHeader(this.title, this.textRenderer);
|
||||
this.body = new OptionList(this.client, this.layout.getWidth(), this.layout.getContentHeight(), this.layout.getHeaderHeight(), 25);
|
||||
this.addItems();
|
||||
this.layout.addBody(body);
|
||||
this.layout.addFooter(ButtonWidget.builder(ScreenTexts.DONE, button -> this.close()).width(200).build());
|
||||
this.layout.forEachChild(this::addDrawableChild);
|
||||
this.refreshWidgetPositions();
|
||||
}
|
||||
|
||||
private void addItems()
|
||||
{
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
ButtonWidget widget = ButtonWidget.builder(Text.of("TEST"), button -> System.out.println("button pressed")).build();
|
||||
this.body.add(widget);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void refreshWidgetPositions()
|
||||
{
|
||||
this.layout.refreshPositions();
|
||||
if (this.body != null)
|
||||
{
|
||||
this.body.position(this.width, this.layout);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close()
|
||||
{
|
||||
if (this.client != null)
|
||||
{
|
||||
this.client.setScreen(this.parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.kasetoatz.fastghast.configscreen;
|
||||
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.Element;
|
||||
import net.minecraft.client.gui.Selectable;
|
||||
import net.minecraft.client.gui.widget.ClickableWidget;
|
||||
import net.minecraft.client.gui.widget.ElementListWidget;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Option extends ElementListWidget.Entry<Option>
|
||||
{
|
||||
private final ClickableWidget widget;
|
||||
|
||||
public Option(ClickableWidget widget)
|
||||
{
|
||||
this.widget = widget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Selectable> selectableChildren()
|
||||
{
|
||||
return List.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Element> children()
|
||||
{
|
||||
return List.of(this.widget);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(DrawContext context, int mouseX, int mouseY, boolean hovered, float deltaTicks)
|
||||
{
|
||||
this.widget.setX(this.getX());
|
||||
this.widget.setY(this.getY());
|
||||
this.widget.setWidth(this.getWidth());
|
||||
this.widget.render(context, mouseX, mouseY, deltaTicks);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.kasetoatz.fastghast.configscreen;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.widget.*;
|
||||
|
||||
public class OptionList extends ElementListWidget<Option>
|
||||
{
|
||||
public OptionList(MinecraftClient client, int width, int height, int y, int itemHeight)
|
||||
{
|
||||
super(client, width, height, y, itemHeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowWidth()
|
||||
{
|
||||
return this.width - 30;
|
||||
}
|
||||
|
||||
public void add(ClickableWidget widget)
|
||||
{
|
||||
this.addEntry(new Option(widget));
|
||||
}
|
||||
}
|
||||
@@ -3,14 +3,23 @@
|
||||
"id": "fastghast",
|
||||
"version": "${version}",
|
||||
"name": "FastGhast",
|
||||
"description": "",
|
||||
"authors": [],
|
||||
"contact": {},
|
||||
"description": "Mod that modifies the speed of the Happy Ghast",
|
||||
"authors": ["KaseToatz"],
|
||||
"contact": {
|
||||
"email": "kasetoatz@kasetoatz.com",
|
||||
"homepage": "https://modrinth.com/mod/fastghast",
|
||||
"issues": "https://git.kasetoatz.com/KaseToatz/FastGhast/issues",
|
||||
"sources": "https://git.kasetoatz.com/KaseToatz/FastGhast"
|
||||
},
|
||||
"license": "MIT",
|
||||
"icon": "icon.png",
|
||||
"environment": "*",
|
||||
"entrypoints": {
|
||||
"main": [
|
||||
"com.kasetoatz.fastghast.Fastghast"
|
||||
],
|
||||
"modmenu": [
|
||||
"com.kasetoatz.fastghast.Fastghast"
|
||||
]
|
||||
},
|
||||
"mixins": [
|
||||
|
||||
BIN
src/main/resources/icon.png
Normal file
BIN
src/main/resources/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 72 KiB |
Reference in New Issue
Block a user