Add keybind to directly list coordinates, Add coordinate convert assets
This commit is contained in:
parent
4d022fcb03
commit
f908d04034
@ -9,6 +9,7 @@ public interface IKeyBinds {
|
||||
public static String DEFAULT = "default";
|
||||
public static String PING = "ping";
|
||||
public static String PING_LOCK = "ping_lock";
|
||||
public static String LIST = "list";
|
||||
|
||||
public List<IKeyBinding> getAllBinds();
|
||||
public IKeyBinding getKeyBind(String name);
|
||||
|
||||
@ -2,4 +2,6 @@ package me.bionicbeanie.mods.savecoords;
|
||||
|
||||
public interface IModGui{
|
||||
void open();
|
||||
|
||||
void openList();
|
||||
}
|
||||
|
||||
@ -5,8 +5,6 @@ import me.bionicbeanie.mods.savecoords.gui.impl.DIContainer;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.font.Font;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
|
||||
public class SaveCoordinatesClient implements ClientModInitializer {
|
||||
@ -14,6 +12,7 @@ public class SaveCoordinatesClient implements ClientModInitializer {
|
||||
private static IKeyBinding defaultKeyBinding = getKeyBinding(IKeyBinds.DEFAULT);
|
||||
private static IKeyBinding pingKeyBinding = getKeyBinding(IKeyBinds.PING);
|
||||
private static IKeyBinding pingLockBinding = getKeyBinding(IKeyBinds.PING_LOCK);
|
||||
private static IKeyBinding listKeyBinding = getKeyBinding(IKeyBinds.LIST);
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
@Override
|
||||
@ -24,6 +23,10 @@ public class SaveCoordinatesClient implements ClientModInitializer {
|
||||
DIContainer.getModGui().open();
|
||||
}
|
||||
|
||||
while(listKeyBinding.wasPressed()) {
|
||||
DIContainer.getModGui().openList();
|
||||
}
|
||||
|
||||
while(pingLockBinding.wasPressed()) {
|
||||
boolean enabled = DIContainer.togglePingBehavior();
|
||||
// TODO : Abstract to a tooltip queue
|
||||
|
||||
@ -4,6 +4,7 @@ public interface TranslationKeys {
|
||||
public static String KEYBIND_DEFAULT = "key.savecoords.default";
|
||||
public static String KEYBIND_PING = "key.savecoords.ping";
|
||||
public static String KEYBIND_PING_LOCK = "key.savecoords.ping_lock";
|
||||
public static String KEYBIND_LIST = "key.savecoords.list";
|
||||
public static String CATEGORY_GENERIC = "category.savecoords.default";
|
||||
public static String MENU_SAVE = "menu.savecoords.save";
|
||||
public static String MENU_BACK = "menu.savecoords.back";
|
||||
|
||||
@ -217,9 +217,9 @@ class ConfigViewHandler extends ViewHandlerBase<List<IKeyBinding>> {
|
||||
private int code;
|
||||
|
||||
ConfigItemPanel() {
|
||||
this.configLabel = new WLabel("Foo");
|
||||
this.configLabel = new WLabel("");
|
||||
this.configButton = new WButton();
|
||||
this.resetButton = new WButton(new LiteralText("RESET"));
|
||||
this.resetButton = new WButton(new TranslatableText(TranslationKeys.MENU_RESET));
|
||||
}
|
||||
|
||||
void setInitialConfig(IKeyBinding config) {
|
||||
@ -234,7 +234,7 @@ class ConfigViewHandler extends ViewHandlerBase<List<IKeyBinding>> {
|
||||
this.resetButton.setOnClick(this::reset);
|
||||
|
||||
this.add(configLabel, 0, 0, 4 * 18, 1 * 9);
|
||||
this.add(configButton, 5 * 18, 0, 4 * 18, 1 * 18);
|
||||
this.add(configButton, 7 * 18, 0, 3 * 18, 1 * 18);
|
||||
this.add(resetButton, 11 * 18, 0, 3 * 18, 1 * 18);
|
||||
}
|
||||
|
||||
|
||||
@ -21,7 +21,6 @@ import me.bionicbeanie.mods.savecoords.model.PlayerRawPosition;
|
||||
import me.bionicbeanie.mods.savecoords.util.ResourceUtils;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
class ListViewHandler extends ViewHandlerBase<Void> {
|
||||
|
||||
@ -112,6 +111,7 @@ class ListViewHandler extends ViewHandlerBase<Void> {
|
||||
private Consumer<PlayerPosition> onEdit;
|
||||
private Consumer<PlayerPosition> onDelete;
|
||||
private INetherCalculator netherCalculator;
|
||||
private boolean coordinateConvertState;
|
||||
|
||||
CoordinatesListItemPanel(Consumer<PlayerPosition> onDelete, Consumer<PlayerPosition> onEdit,
|
||||
Consumer<PlayerRawPosition> onPing, INetherCalculator netherCalculator) {
|
||||
@ -120,11 +120,12 @@ class ListViewHandler extends ViewHandlerBase<Void> {
|
||||
this.onEdit = onEdit;
|
||||
this.onPing = onPing;
|
||||
this.netherCalculator = netherCalculator;
|
||||
this.coordinateConvertState = true;
|
||||
|
||||
this.coordinates = new WLabel("Foo");
|
||||
this.location = new WLabel("Foo");
|
||||
this.world = new WLabel("Foo");
|
||||
this.icon = new WSprite(new Identifier("minecraft:textures/item/ender_eye.png"));
|
||||
this.coordinates = new WLabel("");
|
||||
this.location = new WLabel("");
|
||||
this.world = new WLabel("");
|
||||
this.icon = new WSprite(ResourceUtils.getIdentifier("close"));
|
||||
this.deleteButton = createDeleteButton();
|
||||
this.detailButton = new WButton(new LiteralText(""));
|
||||
this.pingButton = new WButton(new LiteralText(""));
|
||||
@ -132,6 +133,7 @@ class ListViewHandler extends ViewHandlerBase<Void> {
|
||||
|
||||
this.pingButton.setIcon(ResourceUtils.createPingIcon());
|
||||
this.detailButton.setIcon(ResourceUtils.createDetailsIcon());
|
||||
this.convertButton.setIcon(ResourceUtils.createConvertIcon(this.coordinateConvertState));
|
||||
|
||||
this.add(icon, 0, 0, 1 * 9, 1 * 9);
|
||||
this.add(world, 1 * 18, 0, 3 * 18, 1 * 18);
|
||||
@ -139,8 +141,8 @@ class ListViewHandler extends ViewHandlerBase<Void> {
|
||||
this.add(coordinates, 3 * 18, 1 * 18, 9 * 18, 1 * 18);
|
||||
this.add(deleteButton, 13 * 18, 0, 1 * 18, 1 * 18);
|
||||
this.add(detailButton, 12 * 18 - 1, 0, 1 * 18, 1 * 18);
|
||||
this.add(pingButton, 11 * 18 - 2, 0, 1 * 18, 1 * 18);
|
||||
this.add(convertButton, 10 * 18 - 3, 0, 1 * 18, 1 * 18);
|
||||
this.add(convertButton, 11 * 18 - 2, 0, 1 * 18, 1 * 18);
|
||||
this.add(pingButton, 10 * 18 - 3, 0, 1 * 18, 1 * 18);
|
||||
|
||||
this.icon.setSize(1 * 15, 1 * 15);
|
||||
this.world.setSize(3 * 18, 1 * 18);
|
||||
@ -149,6 +151,7 @@ class ListViewHandler extends ViewHandlerBase<Void> {
|
||||
this.deleteButton.setSize(1 * 18, 1 * 18);
|
||||
this.pingButton.setSize(1 * 18, 1 * 18);
|
||||
this.detailButton.setSize(1 * 18, 1 * 18);
|
||||
this.convertButton.setSize(1 * 18, 1 * 18);
|
||||
|
||||
this.setSize(15 * 18, 2 * 18);
|
||||
}
|
||||
@ -177,10 +180,13 @@ class ListViewHandler extends ViewHandlerBase<Void> {
|
||||
}
|
||||
|
||||
private void setRawPosition(PlayerRawPosition position) {
|
||||
|
||||
this.icon.setImage(ResourceUtils.getIdentifier(position.getWorldDimension()));
|
||||
this.coordinates
|
||||
.setText(new LiteralText(position.getX() + ", " + position.getY() + ", " + position.getZ()));
|
||||
this.convertButton.setOnClick(() -> setRawPosition(netherCalculator.convert(position)));
|
||||
this.coordinateConvertState = !coordinateConvertState;
|
||||
this.convertButton.setIcon(ResourceUtils.createConvertIcon(coordinateConvertState));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,6 +46,11 @@ public class SaveCoordinatesGui implements IModGui {
|
||||
showDefaultView(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openList() {
|
||||
showListView();
|
||||
}
|
||||
|
||||
private IViewHandler<PlayerPosition> CreateDefaultViewHandler() {
|
||||
DefaultViewHandler handler = new DefaultViewHandler(fileStore, locator, dimensionAware);
|
||||
|
||||
|
||||
@ -31,6 +31,9 @@ class KeyBinds implements IKeyBinds {
|
||||
KeyBindingEx PING_LOCK = new KeyBindingEx(IKeyBinds.PING_LOCK, TranslationKeys.KEYBIND_PING_LOCK,
|
||||
InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_N, TranslationKeys.CATEGORY_GENERIC);
|
||||
|
||||
KeyBindingEx LIST = new KeyBindingEx(IKeyBinds.LIST, TranslationKeys.KEYBIND_LIST,
|
||||
InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_J, TranslationKeys.CATEGORY_GENERIC);
|
||||
|
||||
private IFileStore fileStore;
|
||||
private Map<String, KeyBindingEx> keyBinds;
|
||||
private List<IKeyBinding> unmodifiableList;
|
||||
@ -40,6 +43,7 @@ class KeyBinds implements IKeyBinds {
|
||||
this.keyBinds = new HashMap<>();
|
||||
|
||||
add(DEFAULT);
|
||||
add(LIST);
|
||||
add(PING);
|
||||
add(PING_LOCK);
|
||||
|
||||
|
||||
@ -21,6 +21,8 @@ public class IdentifiersCache {
|
||||
add("ping", cache);
|
||||
add("close", cache);
|
||||
add("more", cache);
|
||||
add("convert", cache);
|
||||
add("convert_active", cache);
|
||||
}
|
||||
|
||||
public Identifier get(String resourceName) {
|
||||
|
||||
@ -23,4 +23,12 @@ public class ResourceUtils {
|
||||
public static Icon createDetailsIcon() {
|
||||
return new TextureIcon(cache.get("more"));
|
||||
}
|
||||
|
||||
public static Icon createConvertIcon(boolean active) {
|
||||
String resource = "convert";
|
||||
if(active) {
|
||||
resource = "convert_active";
|
||||
}
|
||||
return new TextureIcon(cache.get(resource));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
{
|
||||
"key.savecoords.default": "Open GUI",
|
||||
"key.savecoords.ping": "Beam Location",
|
||||
"key.savecoords.ping_lock": "Lock Beaming",
|
||||
"key.savecoords.default": "Save a coordinate",
|
||||
"key.savecoords.list": "List coordinates",
|
||||
"key.savecoords.ping": "Broadcast position",
|
||||
"key.savecoords.ping_lock": "Lock broadcast",
|
||||
"category.savecoords.default": "Generic",
|
||||
"menu.savecoords.save": "SAVE",
|
||||
"menu.savecoords.reset": "RESET",
|
||||
@ -12,7 +13,7 @@
|
||||
"menu.savecoords.location": "location name",
|
||||
"menu.savecoords.notes": "additional notes",
|
||||
"menu.savecoords.world_name": "world name",
|
||||
"tooltip.savecoords.ping_lock": "You must first enable beaming current location",
|
||||
"tooltip.savecoords.ping_enabled": "Beaming current location is now enabled",
|
||||
"tooltip.savecoords.ping_disabled": "Beaming current location is now disabled"
|
||||
"tooltip.savecoords.ping_lock": "You must first enable broadcasting current location",
|
||||
"tooltip.savecoords.ping_enabled": "Broadcasting current location is now enabled",
|
||||
"tooltip.savecoords.ping_disabled": "Broadcasting current location is now disabled"
|
||||
}
|
||||
BIN
src/main/resources/assets/savecoords/textures/gui/convert.png
Normal file
BIN
src/main/resources/assets/savecoords/textures/gui/convert.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 304 B |
Binary file not shown.
|
After Width: | Height: | Size: 336 B |
Loading…
x
Reference in New Issue
Block a user