Adjust gui

This commit is contained in:
Surya 2021-05-27 23:18:56 +05:30
parent 450737e98d
commit 0ee7dfbde5
4 changed files with 37 additions and 22 deletions

View File

@ -44,7 +44,7 @@ public class SaveCoordinatesGui extends LightweightGuiDescription implements IGu
private IRootGridPanel createRootPanel() {
RootGridPanel panel = new RootGridPanel(18);
panel.setSize(7 * 18, 7 * 18);
panel.setSize(10 * 18, 10 * 18);
setRootPanel(panel);
return panel;

View File

@ -4,6 +4,7 @@ import java.io.IOException;
import java.util.UUID;
import io.github.cottonmc.cotton.gui.widget.WButton;
import io.github.cottonmc.cotton.gui.widget.WLabel;
import io.github.cottonmc.cotton.gui.widget.WText;
import io.github.cottonmc.cotton.gui.widget.WTextField;
import io.github.cottonmc.cotton.gui.widget.WWidget;
@ -31,25 +32,37 @@ public class DefaultViewHandler extends ViewHandlerBase {
PlayerRawPosition rawPosition = locator.locate(client);
WWidget xLabel= CreateLabelForCoorindate("X");
WWidget yLabel= CreateLabelForCoorindate("Y");
WWidget zLabel= CreateLabelForCoorindate("Z");
WWidget xText = CreateWidgetForCoordinate(rawPosition.getX());
WWidget yText = CreateWidgetForCoordinate(rawPosition.getY());
WWidget zText = CreateWidgetForCoordinate(rawPosition.getZ());
root.add(xText, 0, 1, 2, 1);
root.add(yText, 0, 2, 2, 1);
root.add(zText, 0, 3, 2, 1);
root.add(xLabel, 1, 1, 2, 1);
root.add(yLabel, 1, 2, 2, 1);
root.add(zLabel, 1, 3, 2, 1);
root.add(xText, 2, 1, 2, 1);
root.add(yText, 2, 2, 2, 1);
root.add(zText, 2, 3, 2, 1);
WWidget icon = DimensionSpriteUtil.CreateWorldIcon(rawPosition.getWorldDimension());
root.add(icon, 4, 0, 1, 1);
root.add(icon, 6, 1, 2, 2);
WTextField name = CreateNameField();
root.add(name, 2, 2, 5, 1);
root.add(name, 0, 6, 8, 1);
WWidget save = CreateSaveButton(rawPosition, name);
root.add(save, 5, 5, 2, 1);
root.add(save, 9, 6, 2, 1);
WWidget list = CreateListButton();
root.add(list, 0, 5, 2, 1);
root.add(list, 9, 8, 2, 1);
}
private WWidget CreateLabelForCoorindate(String label) {
return new WLabel(label, 0xb80000);
}
private WWidget CreateWidgetForCoordinate(long l) {
@ -57,7 +70,7 @@ public class DefaultViewHandler extends ViewHandlerBase {
}
private WTextField CreateNameField() {
return new WTextField(new LiteralText("name"));
return new WTextField(new LiteralText("location name"));
}
private WWidget CreateSaveButton(PlayerRawPosition rawPosition, WTextField textField) {

View File

@ -45,7 +45,7 @@ public class ListViewHandler extends ViewHandlerBase {
listPanel.setListItemHeight(2 * 18);
root.add(listPanel, 0, 0, 7, 7);
root.add(listPanel, 0, 0, 11, 11);
}
public static class CoordinatesListItemPanel extends WPlainPanel {
@ -59,24 +59,26 @@ public class ListViewHandler extends ViewHandlerBase {
this.coordinates = new WLabel("Foo");
this.location = new WLabel("Foo");
this.icon = new WSprite(new Identifier("minecraft:textures/item/ender_eye.png"));
this.deleteButton = new WButton(new LiteralText("del"));
this.deleteButton = new WButton(new LiteralText("x"));
this.add(icon, 0, 0, 1 * 18, 1 * 18);
this.add(coordinates, 1 * 18, 0, 2 * 18, 1 * 18);
this.add(location, 0, 1 * 18, 2 * 18, 1 * 18);
this.add(deleteButton, 5 * 18, 0, 1 * 18, 1 * 18);
this.add(icon, 0, 0, 1 * 9, 1 * 9);
this.add(location, 1 * 18, 0, 4 * 18, 1 * 18);
this.add(coordinates, 1 * 18, 1 * 18, 9 * 18, 1 * 18);
this.add(deleteButton, 9 * 18, 0, 1 * 18, 1 * 18);
this.icon.setSize(1 * 18, 1 * 18);
this.coordinates.setSize(2 * 18, 1 * 18);
this.location.setSize(3 * 18, 1 * 18);
this.icon.setSize(1 * 15, 1 * 15);
this.location.setSize(9 * 18, 1 * 18);
this.coordinates.setSize(2 * 18, 9 * 18);
this.deleteButton.setSize(1 * 18, 1 * 18);
this.setSize(7 * 18, 2 * 18);
this.setSize(9 * 18, 2 * 18);
}
public void setPosition(PlayerPosition position, IFileStore fileStore, IGui gui) {
this.icon.setImage(DimensionSpriteUtil.CreateWorldIconIdentifier(position.getWorldDimension()));
this.location.setText(new LiteralText(position.getLocationName()));
this.coordinates.setText(new LiteralText(position.getX() + "," + position.getY() + "," + position.getZ()));
this.location.setColor(0x3939ac);
this.coordinates
.setText(new LiteralText(position.getX() + ", " + position.getY() + ", " + position.getZ()));
this.deleteButton.setOnClick(new Runnable() {
@Override

View File

@ -14,7 +14,7 @@ public class DimensionSpriteUtil {
String dimensionItem = "netherite_ingot";
if (dimension.contains("overworld")) {
dimensionItem = "diamond";
dimensionItem = "totem_of_undying";
} else if (dimension.contains("end")) {
dimensionItem = "ender_eye";
}