diff options
Diffstat (limited to 'src/main/java/kr')
26 files changed, 438 insertions, 86 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java b/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java index 9c4357be..2a0d73e0 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java @@ -124,14 +124,12 @@ public class DungeonsGuide implements DGInterface, CloseListener { AhUtils.registerTimer(); - progressbar.step("Downloading Roomdatas"); + progressbar.step("Loading Roomdatas"); try { DungeonRoomInfoRegistry.loadAll(configDir); } catch (BadPaddingException | InvalidKeyException | NoSuchPaddingException | IllegalBlockSizeException | IOException | NoSuchAlgorithmException | InvalidAlgorithmParameterException e) { e.printStackTrace(); } - Keybinds.register(); - progressbar.step("Opening connection"); cosmeticsManager = new CosmeticsManager(); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/Keybinds.java b/src/main/java/kr/syeyoung/dungeonsguide/Keybinds.java index 99fa3d17..1235d29e 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/Keybinds.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/Keybinds.java @@ -18,52 +18,36 @@ package kr.syeyoung.dungeonsguide; +import kr.syeyoung.dungeonsguide.events.KeyBindPressedEvent; import kr.syeyoung.dungeonsguide.features.FeatureRegistry; import net.minecraft.client.Minecraft; +import net.minecraft.client.settings.GameSettings; import net.minecraft.client.settings.KeyBinding; import net.minecraft.util.ChatComponentText; +import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.InputEvent; import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; public class Keybinds { - public static KeyBinding editingSession; - public static KeyBinding sendBombdefuse; - public static KeyBinding nextSecret; - public static KeyBinding refreshPathfind; - public static KeyBinding togglePathfind; - public static KeyBinding freezeLines; - - public static void register() - { - editingSession = new KeyBinding("Start editing session", Keyboard.KEY_NONE, "Dungeons Guide"); - ClientRegistry.registerKeyBinding(editingSession); - sendBombdefuse = new KeyBinding("Send and save bombdefuse solution", Keyboard.KEY_F, "Dungeons Guide"); - ClientRegistry.registerKeyBinding(sendBombdefuse); - nextSecret = new KeyBinding("Navigate to next secret. (Req option enabled at /dg)", Keyboard.KEY_R, "Dungeons Guide"); - ClientRegistry.registerKeyBinding(nextSecret); - togglePathfind = new KeyBinding("Toggle Pathfind. (Req option enabled at /dg)", Keyboard.KEY_NONE, "Dungeons Guide"); - ClientRegistry.registerKeyBinding(togglePathfind); - refreshPathfind = new KeyBinding("Refresh or Pathfind Pathfindline to hovered secret", Keyboard.KEY_NONE, "Dungeons Guide"); - ClientRegistry.registerKeyBinding(refreshPathfind); - freezeLines = new KeyBinding("Toggle freeze pathfind lines", Keyboard.KEY_NONE, "Dungeons Guide"); - ClientRegistry.registerKeyBinding(freezeLines); - } - - public static boolean togglePathfindStatus = false; @SubscribeEvent public void onTogglePathfindStatus(InputEvent.KeyInputEvent keyInputEvent) { - if (togglePathfind.isKeyDown()) - togglePathfindStatus = !togglePathfindStatus; - - if (freezeLines.isKeyDown()) { - FeatureRegistry.SECRET_FREEZE_LINES.setEnabled(!FeatureRegistry.SECRET_FREEZE_LINES.isEnabled()); - try { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §fToggled Pathfind Freeze to §e"+(FeatureRegistry.SECRET_FREEZE_LINES.isEnabled() ? "on":"off"))); - } catch (Exception ignored) {} + if (Keyboard.getEventKeyState()) { + int key = Keyboard.getEventKey() == 0 ? Keyboard.getEventCharacter() + 256 : Keyboard.getEventKey(); + KeyBindPressedEvent keyBindPressedEvent = new KeyBindPressedEvent(key); + MinecraftForge.EVENT_BUS.post(keyBindPressedEvent); + } + } + @SubscribeEvent + public void onMousePressed(InputEvent.MouseInputEvent mouseInputEvent) { + if (Mouse.getEventButtonState()) { + int key = Mouse.getEventButton() - 100; + KeyBindPressedEvent keyBindPressedEvent = new KeyBindPressedEvent(key); + MinecraftForge.EVENT_BUS.post(keyBindPressedEvent); } } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MFeature.java index 90acceb9..49f637a5 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MFeature.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MFeature.java @@ -71,7 +71,7 @@ public class MFeature extends MPanel { } if (abstractFeature.getParameters().size() != 0) { MButton button = new MButton(); - button.setText("Edit"); + button.setText("Settings"); button.setOnActionPerformed(new Runnable() { @Override public void run() { diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MParameterEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MParameterEdit.java index b4b2a8e8..8ed0e028 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MParameterEdit.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MParameterEdit.java @@ -89,7 +89,14 @@ public class MParameterEdit extends MPanel { ((MToggleButton)valueEdit).setOnToggle(() -> { parameter.setValue(((MToggleButton) valueEdit).isEnabled()); }); - } else { + } else if (parameter.getValue_type().equals("keybind")) { + valueEdit = new MKeyEditButton(); + ((MKeyEditButton)valueEdit).setKey((Integer) parameter.getValue()); + ((MKeyEditButton)valueEdit).setOnKeyEdit(() -> { + parameter.setValue(((MKeyEditButton) valueEdit).getKey()); + }); + ((MKeyEditButton)valueEdit).setBorder(RenderUtils.blendTwoColors(0xFF141414,0x7702EE67)); + }else { valueEdit = new MLabel(); ((MLabel)valueEdit).setText("????"); } @@ -108,10 +115,11 @@ public class MParameterEdit extends MPanel { add(valueEditHolder); valueEditHolder.add(valueEdit); } - public MParameterEdit(AbstractFeature abstractFeature, FeatureParameter parameter, RootConfigPanel rootConfigPanel, MPanel valueEdit) { + public MParameterEdit(AbstractFeature abstractFeature, FeatureParameter parameter, RootConfigPanel rootConfigPanel, MPanel valueEdit, Predicate<FeatureParameter> isDisabled) { this.abstractFeature = abstractFeature; this.featureParameter = parameter; this.rootConfigPanel = rootConfigPanel; + this.isDisabled = isDisabled; valueEditHolder = new MPanel() { diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCKeybind.java b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCKeybind.java new file mode 100644 index 00000000..4ae89395 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCKeybind.java @@ -0,0 +1,39 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package kr.syeyoung.dungeonsguide.config.types; + +import com.google.gson.JsonElement; +import com.google.gson.JsonPrimitive; + +public class TCKeybind implements TypeConverter<Integer> { + @Override + public String getTypeString() { + return "keybind"; + } + + @Override + public Integer deserialize(JsonElement element) { + return element.getAsInt(); + } + + @Override + public JsonElement serialize(Integer element) { + return new JsonPrimitive(element); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverterRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverterRegistry.java index d183cffb..abffd34a 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverterRegistry.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverterRegistry.java @@ -49,5 +49,6 @@ public class TypeConverterRegistry { register(new TCTextStyleList()); register(new TCTextStyle()); register(new TCStringList()); + register(new TCKeybind()); } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java index 754bdf35..dc0854c5 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java @@ -23,6 +23,7 @@ import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.features.impl.secret.FeatureTogglePathfind; import kr.syeyoung.dungeonsguide.utils.RenderUtils; import lombok.Data; import net.minecraft.client.Minecraft; @@ -71,7 +72,7 @@ public class ActionMove extends AbstractAction { RenderUtils.drawTextAtWorld("Destination", pos.getX() + 0.5f, pos.getY() + 0.5f + scale, pos.getZ() + 0.5f, 0xFF00FF00, flag ? 2f : 1f, true, false, partialTicks); RenderUtils.drawTextAtWorld(String.format("%.2f",MathHelper.sqrt_double(pos.distanceSq(Minecraft.getMinecraft().thePlayer.getPosition())))+"m", pos.getX() + 0.5f, pos.getY() + 0.5f - scale, pos.getZ() + 0.5f, 0xFFFFFF00, flag ? 2f : 1f, true, false, partialTicks); - if (!FeatureRegistry.SECRET_TOGGLE_KEY.isEnabled() || !Keybinds.togglePathfindStatus) { + if (!FeatureRegistry.SECRET_TOGGLE_KEY.isEnabled() || !FeatureRegistry.SECRET_TOGGLE_KEY.togglePathfindStatus) { if (poses != null){ RenderUtils.drawLinesVec3(poses, actionRouteProperties.getLineColor(), actionRouteProperties.getLineWidth(), partialTicks, true); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java index d990a835..11aecad1 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java @@ -71,7 +71,7 @@ public class ActionMoveNearestAir extends AbstractAction { RenderUtils.drawTextAtWorld("Destination", pos.getX() + 0.5f, pos.getY() + 0.5f + scale, pos.getZ() + 0.5f, 0xFF00FF00, flag ? 2f : 1f, true, false, partialTicks); RenderUtils.drawTextAtWorld(String.format("%.2f",MathHelper.sqrt_double(pos.distanceSq(Minecraft.getMinecraft().thePlayer.getPosition())))+"m", pos.getX() + 0.5f, pos.getY() + 0.5f - scale, pos.getZ() + 0.5f, 0xFFFFFF00, flag ? 2f : 1f, true, false, partialTicks); - if (!FeatureRegistry.SECRET_TOGGLE_KEY.isEnabled() || !Keybinds.togglePathfindStatus) { + if (!FeatureRegistry.SECRET_TOGGLE_KEY.isEnabled() || !FeatureRegistry.SECRET_TOGGLE_KEY.togglePathfindStatus) { if (poses != null){ RenderUtils.drawLinesVec3(poses, actionRouteProperties.getLineColor(), actionRouteProperties.getLineWidth(), partialTicks, true); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java index d01a5ea9..49e8a40c 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java @@ -60,14 +60,12 @@ import net.minecraftforge.event.entity.living.LivingEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.fml.client.CustomModLoadingErrorDisplayException; -import net.minecraftforge.fml.client.FMLClientHandler; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.InputEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL14; @@ -395,7 +393,7 @@ public class DungeonListener { } } @SubscribeEvent() - public void onKey2(InputEvent.KeyInputEvent keyInputEvent) { + public void onKey2(KeyBindPressedEvent keyInputEvent) { try { SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); if (!skyblockStatus.isOnDungeon()) return; @@ -407,14 +405,14 @@ public class DungeonListener { Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); if (context.getBossfightProcessor() != null) { - context.getBossfightProcessor().onKeyPress(keyInputEvent); + context.getBossfightProcessor().onKeybindPress(keyInputEvent); } RoomProcessor roomProcessor = null; try { DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); if (dungeonRoom != null) { if (dungeonRoom.getRoomProcessor() != null) { - dungeonRoom.getRoomProcessor().onKeyPress(keyInputEvent); + dungeonRoom.getRoomProcessor().onKeybindPress(keyInputEvent); } } } catch (Throwable t) { @@ -490,8 +488,8 @@ public class DungeonListener { } @SubscribeEvent - public void onKeyInput(InputEvent.KeyInputEvent keyInputEvent) { - if (FeatureRegistry.DEBUG.isEnabled() && FeatureRegistry.ADVANCED_ROOMEDIT.isEnabled() && Keybinds.editingSession.isKeyDown() ){ + public void onKeyInput(KeyBindPressedEvent keyInputEvent) { + if (FeatureRegistry.DEBUG.isEnabled() && FeatureRegistry.ADVANCED_ROOMEDIT.isEnabled() && keyInputEvent.getKey() == FeatureRegistry.ADVANCED_ROOMEDIT.<Integer>getParameter("key").getValue() ){ EditingContext ec = EditingContext.getEditingContext(); if (ec == null) { DungeonContext context = DungeonsGuide.getDungeonsGuide().getSkyblockStatus().getContext(); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/FeatureListener.java b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/FeatureListener.java index 20aeb460..22057ab3 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/FeatureListener.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/FeatureListener.java @@ -55,6 +55,20 @@ public class FeatureListener { t.printStackTrace(); } } + + @SubscribeEvent + public void onKeybindPress(KeyBindPressedEvent keyBindPressedEvent) { + try { + for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { + if (abstractFeature instanceof KeybindPressedListener) { + ((KeybindPressedListener) abstractFeature).onKeybindPress(keyBindPressedEvent); + } + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + @SubscribeEvent public void onStomp(StompConnectedEvent stompConnectedEvent) { try { diff --git a/src/main/java/kr/syeyoung/dungeonsguide/events/KeyBindPressedEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/events/KeyBindPressedEvent.java new file mode 100644 index 00000000..c277b227 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/events/KeyBindPressedEvent.java @@ -0,0 +1,28 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package kr.syeyoung.dungeonsguide.events; + +import lombok.AllArgsConstructor; +import lombok.Data; +import net.minecraftforge.fml.common.eventhandler.Event; + +@Data @AllArgsConstructor +public class KeyBindPressedEvent extends Event { + private int key; +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java index ef258b5d..a9281c1d 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java @@ -18,6 +18,12 @@ package kr.syeyoung.dungeonsguide.features; +import com.google.common.base.Supplier; +import kr.syeyoung.dungeonsguide.Keybinds; +import kr.syeyoung.dungeonsguide.config.guiconfig.ConfigPanelCreator; +import kr.syeyoung.dungeonsguide.config.guiconfig.MFeatureEdit; +import kr.syeyoung.dungeonsguide.config.guiconfig.MParameterEdit; +import kr.syeyoung.dungeonsguide.config.guiconfig.RootConfigPanel; import kr.syeyoung.dungeonsguide.config.types.AColor; import kr.syeyoung.dungeonsguide.features.impl.advanced.FeatureDebug; import kr.syeyoung.dungeonsguide.features.impl.advanced.FeatureDebuggableMap; @@ -38,7 +44,10 @@ import kr.syeyoung.dungeonsguide.features.impl.party.customgui.FeatureCustomPart import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.FeatureViewPlayerOnJoin; import kr.syeyoung.dungeonsguide.features.impl.secret.*; import kr.syeyoung.dungeonsguide.features.impl.secret.mechanicbrowser.FeatureMechanicBrowse; +import kr.syeyoung.dungeonsguide.gui.MPanel; +import kr.syeyoung.dungeonsguide.gui.elements.MKeyEditButton; import lombok.Getter; +import org.lwjgl.input.Keyboard; import java.util.ArrayList; import java.util.HashMap; @@ -72,7 +81,11 @@ public class FeatureRegistry { } public static final SimpleFeature DEBUG = register(new FeatureDebug()); - public static final SimpleFeature ADVANCED_ROOMEDIT = register(new SimpleFeature("Advanced", "Room Edit", "Allow editing dungeon rooms\n\nWarning: using this feature can break or freeze your Minecraft\nThis is only for advanced users only", "advanced.roomedit", false)); + public static final SimpleFeature ADVANCED_ROOMEDIT = register(new SimpleFeature("Advanced", "Room Edit", "Allow editing dungeon rooms\n\nWarning: using this feature can break or freeze your Minecraft\nThis is only for advanced users only", "advanced.roomedit", false){ + { + parameters.put("key", new FeatureParameter<Integer>("key", "Key","Press to edit room", Keyboard.KEY_R, "keybind")); + } + }); public static final FeatureRoomDebugInfo ADVANCED_DEBUG_ROOM = register(new FeatureRoomDebugInfo()); public static final FeatureDebuggableMap ADVANCED_DEBUGGABLE_MAP = register(new FeatureDebuggableMap()); public static final FeatureRoomCoordDisplay ADVANCED_COORDS = register(new FeatureRoomCoordDisplay()); @@ -100,7 +113,11 @@ public class FeatureRegistry { public static final SimpleFeature SOLVER_BOX_DISABLE_TEXT = register(new SimpleFeature("Solver.Floor 3+", "Box Puzzle Solver Disable text", "Disable 'Type recalc to recalculate solution' showing up on top left.\nYou can still type recalc to recalc solution after disabling this feature", "solver.boxrecalc", false)); public static final SimpleFeature SOLVER_CREEPER = register(new SimpleFeature("Solver.Any Floor", "Creeper", "Draws line between prismarine lamps in creeper room", "solver.creeper")); public static final SimpleFeature SOLVER_TELEPORT = register(new SimpleFeature("Solver.Any Floor", "Teleport", "Shows teleport pads you've visited in a teleport maze room", "solver.teleport")); - public static final SimpleFeature SOLVER_BOMBDEFUSE = register(new SimpleFeature("Solver.Floor 7+", "Bomb Defuse", "Communicates with others dg using key 'F' for solutions and displays it", "solver.bombdefuse")); + public static final SimpleFeature SOLVER_BOMBDEFUSE = register(new SimpleFeature("Solver.Floor 7+", "Bomb Defuse", "Communicates with others dg using key 'F' for solutions and displays it", "solver.bombdefuse") { + { + parameters.put("key", new FeatureParameter<Integer>("key", "Key","Press to send solution in chat", Keyboard.KEY_NONE, "keybind")); + } + }); public static final FeatureTooltipDungeonStat ETC_DUNGEONSTAT = register(new FeatureTooltipDungeonStat()); public static final FeatureTooltipPrice ETC_PRICE = register(new FeatureTooltipPrice()); @@ -166,8 +183,8 @@ public class FeatureRegistry { public static final FeatureActions SECRET_ACTIONS = register(new FeatureActions()); public static final SimpleFeature SECRET_PATHFIND_STRATEGY = register(new SimpleFeature("Dungeon Secrets", "Use NEW JPS Optimization instead of standard A Star", "Faster, and accurate routes.", "secret.secretpathfind.algorithm", true)); - public static final SimpleFeature SECRET_TOGGLE_KEY = register(new SimpleFeature("Dungeon Secrets.Keybinds", "Toggle Pathfind Lines", "A key for toggling pathfound line visibility.\nChange key at your key settings (Settings -> Controls)", "secret.togglePathfind")); - public static final SimpleFeature SECRET_FREEZE_LINES = register(new FeatureFreezePathfind()); + public static final FeatureTogglePathfind SECRET_TOGGLE_KEY = register(new FeatureTogglePathfind()); + public static final FeatureFreezePathfind SECRET_FREEZE_LINES = register(new FeatureFreezePathfind()); public static final FeatureCreateRefreshLine SECRET_CREATE_REFRESH_LINE = register(new FeatureCreateRefreshLine()); static { categoryDescription.put("ROOT.Dungeon Secrets.Keybinds", "Useful keybinds / Toggle Pathfind lines, Freeze Pathfind lines, Refresh pathfind line or Trigger pathfind (you would want to use it, if you're using Pathfind to All)"); @@ -176,7 +193,12 @@ public class FeatureRegistry { public static final SimpleFeature SECRET_AUTO_BROWSE_NEXT = register(new SimpleFeature("Dungeon Secrets.Legacy AutoPathfind", "Auto Pathfind to next secret", "Auto browse best next secret after current one completes.\nthe first pathfinding of first secret needs to be triggered first in order for this option to work", "secret.autobrowse", false)); public static final SimpleFeature SECRET_AUTO_START = register(new SimpleFeature("Dungeon Secrets.Legacy AutoPathfind", "Auto pathfind to new secret", "Auto browse best secret upon entering the room.", "secret.autouponenter", false)); - public static final SimpleFeature SECRET_NEXT_KEY = register(new SimpleFeature("Dungeon Secrets.Legacy AutoPathfind", "Auto Pathfind to new secret upon pressing a key", "Auto browse the best next secret when you press key.\nChange key at your key settings (Settings -> Controls)", "secret.keyfornext", false)); + public static final SimpleFeature SECRET_NEXT_KEY = register(new SimpleFeature("Dungeon Secrets.Legacy AutoPathfind", "Auto Pathfind to new secret upon pressing a key", "Auto browse the best next secret when you press key.\nPress settings to edit the key", "secret.keyfornext", false) { + { + parameters.put("key", new FeatureParameter<Integer>("key", "Key","Press to navigate to next best secret", Keyboard.KEY_NONE, "keybind")); + } + }); + public static final PathfindLineProperties SECRET_LINE_PROPERTIES_AUTOPATHFIND = register(new PathfindLineProperties("Dungeon Secrets.Legacy AutoPathfind", "Line Settings", "Line Settings when pathfinding using above features", "secret.lineproperties.autopathfind", true, SECRET_LINE_PROPERTIES_GLOBAL)); public static final FeaturePathfindToAll SECRET_PATHFIND_ALL = register(new FeaturePathfindToAll()); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/advanced/FeatureDebug.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/advanced/FeatureDebug.java index 85e3a83d..a254f0db 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/advanced/FeatureDebug.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/advanced/FeatureDebug.java @@ -56,7 +56,7 @@ public class FeatureDebug extends SimpleFeature { public String getText() { return isEnabled() ? "Enabled!" : "Incorrect Key"; } - })); + }, (a) -> false)); return featureEdit; } }); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureCreateRefreshLine.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureCreateRefreshLine.java index 15a5ee4d..1c49b636 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureCreateRefreshLine.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureCreateRefreshLine.java @@ -19,6 +19,7 @@ package kr.syeyoung.dungeonsguide.features.impl.secret; import com.google.common.base.Supplier; +import kr.syeyoung.dungeonsguide.Keybinds; import kr.syeyoung.dungeonsguide.config.guiconfig.ConfigPanelCreator; import kr.syeyoung.dungeonsguide.config.guiconfig.MFeatureEdit; import kr.syeyoung.dungeonsguide.config.guiconfig.MParameterEdit; @@ -27,14 +28,20 @@ import kr.syeyoung.dungeonsguide.config.types.AColor; import kr.syeyoung.dungeonsguide.features.FeatureParameter; import kr.syeyoung.dungeonsguide.features.SimpleFeature; import kr.syeyoung.dungeonsguide.gui.MPanel; +import kr.syeyoung.dungeonsguide.gui.elements.MKeyEditButton; +import org.lwjgl.input.Keyboard; + +import java.util.LinkedHashMap; public class FeatureCreateRefreshLine extends SimpleFeature { public FeatureCreateRefreshLine() { - super("Dungeon Secrets.Keybinds", "Refresh pathfind line or Trigger pathfind", "A keybind for creating or refresh pathfind lines for pathfind contexts that doesn't have line, or contexts that has refresh rate set to -1.\nChange key at your key settings (Settings -> Controls)", "secret.refreshPathfind", true); - + super("Dungeon Secrets.Keybinds", "Refresh pathfind line or Trigger pathfind", "A keybind for creating or refresh pathfind lines for pathfind contexts that doesn't have line, or contexts that has refresh rate set to -1.\nPress settings to edit the key", "secret.refreshPathfind", true); + this.parameters = new LinkedHashMap<>(); + this.parameters.put("key", new FeatureParameter<Integer>("key", "Key","Press to refresh or create pathfind line", Keyboard.KEY_NONE, "keybind")); this.parameters.put("pathfind", new FeatureParameter<Boolean>("pathfind", "Enable Pathfinding", "Force Enable pathfind for future actions when used", false, "boolean")); this.parameters.put("refreshrate", new FeatureParameter<Integer>("refreshrate", "Line Refreshrate", "Ticks to wait per line refresh, to be overriden. If the line already has pathfind enabled, this value does nothing. Specify it to -1 to don't refresh line at all", 10, "integer")); } + public int getKeybind() {return this.<Integer>getParameter("key").getValue();} public boolean isPathfind() { return this.<Boolean>getParameter("pathfind").getValue(); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureFreezePathfind.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureFreezePathfind.java index a8102ad2..e492bd1c 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureFreezePathfind.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureFreezePathfind.java @@ -18,14 +18,40 @@ package kr.syeyoung.dungeonsguide.features.impl.secret; +import com.google.common.base.Supplier; import kr.syeyoung.dungeonsguide.DungeonsGuide; +import kr.syeyoung.dungeonsguide.Keybinds; import kr.syeyoung.dungeonsguide.SkyblockStatus; +import kr.syeyoung.dungeonsguide.config.guiconfig.ConfigPanelCreator; +import kr.syeyoung.dungeonsguide.config.guiconfig.MFeatureEdit; +import kr.syeyoung.dungeonsguide.config.guiconfig.MParameterEdit; +import kr.syeyoung.dungeonsguide.config.guiconfig.RootConfigPanel; +import kr.syeyoung.dungeonsguide.events.KeyBindPressedEvent; +import kr.syeyoung.dungeonsguide.features.AbstractFeature; +import kr.syeyoung.dungeonsguide.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.features.FeatureRegistry; import kr.syeyoung.dungeonsguide.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.features.listener.KeybindPressedListener; +import kr.syeyoung.dungeonsguide.gui.MPanel; +import kr.syeyoung.dungeonsguide.gui.elements.MKeyEditButton; +import net.minecraft.client.Minecraft; +import net.minecraft.client.settings.GameSettings; +import net.minecraft.util.ChatComponentText; +import org.lwjgl.input.Keyboard; -public class FeatureFreezePathfind extends SimpleFeature { +public class FeatureFreezePathfind extends SimpleFeature implements KeybindPressedListener { public FeatureFreezePathfind() { - super("Dungeon Secrets.Keybinds", "Global Freeze Pathfind", "Freeze Pathfind, meaning the pathfind lines won't change when you move. Can be toggled with key set in Minecraft Key Settings", "secret.freezepathfind", false); + super("Dungeon Secrets.Keybinds", "Global Freeze Pathfind", "Freeze Pathfind, meaning the pathfind lines won't change when you move.\nPress settings to edit the key", "secret.freezepathfind", false); + this.parameters.put("key", new FeatureParameter<Integer>("key", "Key", "Press to toggle freeze pathfind", Keyboard.KEY_NONE, "keybind")); } - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); + @Override + public void onKeybindPress(KeyBindPressedEvent keyBindPressedEvent) { + if (keyBindPressedEvent.getKey() == this.<Integer>getParameter("key").getValue()) { + setEnabled(!isEnabled()); + try { + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §fToggled Pathfind Freeze to §e"+(FeatureRegistry.SECRET_FREEZE_LINES.isEnabled() ? "on":"off"))); + } catch (Exception ignored) {} + } + } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureTogglePathfind.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureTogglePathfind.java new file mode 100644 index 00000000..aa128d92 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureTogglePathfind.java @@ -0,0 +1,55 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package kr.syeyoung.dungeonsguide.features.impl.secret; + +import com.google.common.base.Supplier; +import kr.syeyoung.dungeonsguide.Keybinds; +import kr.syeyoung.dungeonsguide.config.guiconfig.ConfigPanelCreator; +import kr.syeyoung.dungeonsguide.config.guiconfig.MFeatureEdit; +import kr.syeyoung.dungeonsguide.config.guiconfig.MParameterEdit; +import kr.syeyoung.dungeonsguide.config.guiconfig.RootConfigPanel; +import kr.syeyoung.dungeonsguide.events.KeyBindPressedEvent; +import kr.syeyoung.dungeonsguide.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.features.listener.KeybindPressedListener; +import kr.syeyoung.dungeonsguide.gui.MPanel; +import kr.syeyoung.dungeonsguide.gui.elements.MKeyEditButton; +import lombok.Getter; +import net.minecraft.client.Minecraft; +import net.minecraft.util.ChatComponentText; +import org.lwjgl.input.Keyboard; + +public class FeatureTogglePathfind extends SimpleFeature implements KeybindPressedListener { + public FeatureTogglePathfind() { + super("Dungeon Secrets.Keybinds", "Toggle Pathfind Lines", "A key for toggling pathfound line visibility.\nPress settings to edit the key", "secret.togglePathfind"); + this.parameters.put("key", new FeatureParameter<Integer>("key", "Key", "Press to toggle pathfind lines", Keyboard.KEY_NONE, "keybind")); + } + public boolean togglePathfindStatus = false; + + @Override + public void onKeybindPress(KeyBindPressedEvent keyBindPressedEvent) { + if (keyBindPressedEvent.getKey() == this.<Integer>getParameter("key").getValue() && isEnabled()) { + togglePathfindStatus = !togglePathfindStatus; + try { + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §fToggled Pathfind Line visibility to §e"+(togglePathfindStatus ? "on":"off"))); + } catch (Exception ignored) {} + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/KeybindPressedListener.java b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/KeybindPressedListener.java new file mode 100644 index 00000000..3d67e326 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/KeybindPressedListener.java @@ -0,0 +1,25 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package kr.syeyoung.dungeonsguide.features.listener; + +import kr.syeyoung.dungeonsguide.events.KeyBindPressedEvent; + +public interface KeybindPressedListener { + void onKeybindPress(KeyBindPressedEvent keyBindPressedEvent); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextHUDFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextHUDFeature.java index 2fa2ef89..b0cda000 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextHUDFeature.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextHUDFeature.java @@ -140,7 +140,7 @@ public abstract class TextHUDFeature extends GuiFeature implements StyledTextPro mStringSelectionButton.setOnUpdate(() -> { TextHUDFeature.this.<String>getParameter("alignment").setValue(mStringSelectionButton.getSelected()); }); - featureEdit.addParameterEdit("alignment", new MParameterEdit(TextHUDFeature.this, TextHUDFeature.this.<String>getParameter("alignment"), rootConfigPanel, mStringSelectionButton)); + featureEdit.addParameterEdit("alignment", new MParameterEdit(TextHUDFeature.this, TextHUDFeature.this.<String>getParameter("alignment"), rootConfigPanel, mStringSelectionButton, (a) -> false)); for (FeatureParameter parameter: getParameters()) { if (parameter.getKey().equals("textStylesNEW")) continue; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MKeyEditButton.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MKeyEditButton.java new file mode 100755 index 00000000..f02a041b --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MKeyEditButton.java @@ -0,0 +1,148 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package kr.syeyoung.dungeonsguide.gui.elements; + +import kr.syeyoung.dungeonsguide.gui.MPanel; +import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import kr.syeyoung.dungeonsguide.utils.cursor.EnumCursor; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.audio.PositionedSoundRecord; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.settings.GameSettings; +import net.minecraft.client.settings.KeyBinding; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; + +import java.awt.*; + +@Getter +@Setter +public class MKeyEditButton extends MPanel { + private int key; + private Runnable onKeyEdit; + + private Color foreground = Color.white; + private int background = RenderUtils.blendAlpha(0xFF141414, 0.08f); + private int hover = RenderUtils.blendAlpha(0xFF141414, 0.14f); + private int clicked = RenderUtils.blendAlpha(0xFF141414, 0.16f); + private int border = 0x0; + private int disabled =0xFF141414; + private int roundness = 0; + + private boolean enabled = true; + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle clip) { + Dimension bounds = getSize(); + + int bg = background; + if (!enabled) { + bg = disabled; + } else if (getTooltipsOpen() > 0) { + } else if (selected) { + bg = clicked; + } else if (new Rectangle(new Point(0,0),bounds).contains(relMousex0, relMousey0)) { + bg = hover; + } + if (roundness == 0) { + if (((border >> 24) & 0xFF) == 0) + Gui.drawRect(0, 0, getBounds().width, getBounds().height, bg); + else { + Gui.drawRect(0, 0, getBounds().width, getBounds().height, border); + Gui.drawRect(1, 1, getBounds().width - 1, getBounds().height - 1, bg); + } + } else { + if (((border >> 24) & 0xFF) == 0) + RenderUtils.drawRoundedRectangle(0, 0, getBounds().width, getBounds().height, roundness, Math.PI/8, bg); + else { + RenderUtils.drawRoundedRectangle(0, 0, getBounds().width, getBounds().height, roundness, Math.PI/8, border); + RenderUtils.drawRoundedRectangle(1, 1, getBounds().width-2, getBounds().height-2, roundness, Math.PI/8, bg); + } + GlStateManager.enableTexture2D(); + } + + String str = GameSettings.getKeyDisplayString(key); + if (selected) str = "> "+str+" <"; + FontRenderer renderer = Minecraft.getMinecraft().fontRendererObj; + int width = renderer.getStringWidth(str); + int x = (getBounds().width - width) / 2; + int y = (getBounds().height - renderer.FONT_HEIGHT) / 2 + 1; + + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + renderer.drawString(str, x,y, foreground.getRGB()); + } + + private boolean selected; + @Override + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + if (lastAbsClip.contains(absMouseX, absMouseY) && getTooltipsOpen() == 0) { + if (selected) { + key = -100 + mouseButton; + selected = false; + if (onKeyEdit != null) + onKeyEdit.run(); + } else { + selected = true; + } + Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F)); + } else { + selected = false; + } + } + + @Override + public void mouseReleased(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int state) { + + } + + + @Override + public void mouseMoved(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0) { + if (lastAbsClip.contains(absMouseX, absMouseY) && enabled) + setCursor(EnumCursor.POINTING_HAND); + } + + @Override + public void keyPressed(char typedChar, int keyCode) { + if (!selected) return; + if (keyCode == 1) { + key = 0; + } else if (keyCode != 0) { + key = keyCode; + } else if (typedChar > 0) { + key = typedChar + 256; + } + selected = false; + if (onKeyEdit != null) + onKeyEdit.run(); + throw new RuntimeException("hack to stop event propagation"); + } + + @Override + public Dimension getPreferredSize() { + return new Dimension(80, 15); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java index 0b002161..0ec0dd83 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java @@ -31,13 +31,13 @@ import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonMechanic; import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonSecret; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.events.BlockUpdateEvent; +import kr.syeyoung.dungeonsguide.events.KeyBindPressedEvent; import kr.syeyoung.dungeonsguide.events.PlayerInteractEntityEvent; import kr.syeyoung.dungeonsguide.features.FeatureRegistry; import kr.syeyoung.dungeonsguide.pathfinding.NodeProcessorDungeonRoom; import kr.syeyoung.dungeonsguide.roomedit.EditingContext; import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonAddSet; import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonRoomEdit; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; import kr.syeyoung.dungeonsguide.utils.VectorUtils; import lombok.Getter; import lombok.Setter; @@ -57,7 +57,6 @@ import net.minecraftforge.client.event.GuiScreenEvent; import net.minecraftforge.event.entity.living.LivingDeathEvent; import net.minecraftforge.event.entity.living.LivingEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; -import net.minecraftforge.fml.common.gameevent.InputEvent; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL14; @@ -322,10 +321,10 @@ public class GeneralRoomProcessor implements RoomProcessor { } @Override - public void onKeyPress(InputEvent.KeyInputEvent keyInputEvent) { - if (FeatureRegistry.SECRET_NEXT_KEY.isEnabled() && Keybinds.nextSecret.isKeyDown()) { + public void onKeybindPress(KeyBindPressedEvent keyInputEvent) { + if (FeatureRegistry.SECRET_NEXT_KEY.isEnabled() && FeatureRegistry.SECRET_NEXT_KEY.<Integer>getParameter("key").getValue() == keyInputEvent.getKey()) { searchForNextTarget(); - } else if (Keybinds.refreshPathfind.isKeyDown() && FeatureRegistry.SECRET_CREATE_REFRESH_LINE.isEnabled()) { + } else if (FeatureRegistry.SECRET_CREATE_REFRESH_LINE.getKeybind() == keyInputEvent.getKey() && FeatureRegistry.SECRET_CREATE_REFRESH_LINE.isEnabled()) { ActionRoute actionRoute = getBestFit(0); if (actionRoute.getCurrentAction() instanceof ActionMove) { ActionMove ac = (ActionMove) actionRoute.getCurrentAction(); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessor.java index 848bd71a..d340366e 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessor.java @@ -18,17 +18,14 @@ package kr.syeyoung.dungeonsguide.roomprocessor; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.events.BlockUpdateEvent; +import kr.syeyoung.dungeonsguide.events.KeyBindPressedEvent; import kr.syeyoung.dungeonsguide.events.PlayerInteractEntityEvent; import net.minecraft.util.IChatComponent; import net.minecraftforge.client.event.GuiScreenEvent; -import net.minecraftforge.client.event.RenderLivingEvent; import net.minecraftforge.event.entity.living.LivingDeathEvent; import net.minecraftforge.event.entity.living.LivingEvent; -import net.minecraftforge.event.entity.player.EntityInteractEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; -import net.minecraftforge.fml.common.gameevent.InputEvent; public interface RoomProcessor { void tick(); @@ -43,7 +40,7 @@ public interface RoomProcessor { void onEntityUpdate(LivingEvent.LivingUpdateEvent updateEvent); void onEntityDeath(LivingDeathEvent deathEvent); - void onKeyPress(InputEvent.KeyInputEvent keyInputEvent); + void onKeybindPress(KeyBindPressedEvent keyInputEvent); void onInteract(PlayerInteractEntityEvent event); void onInteractBlock(PlayerInteractEvent event); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/RoomProcessorBombDefuseSolver.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/RoomProcessorBombDefuseSolver.java index 0623174e..0fa14951 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/RoomProcessorBombDefuseSolver.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/RoomProcessorBombDefuseSolver.java @@ -22,6 +22,7 @@ import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.DungeonsGuide; +import kr.syeyoung.dungeonsguide.events.KeyBindPressedEvent; import kr.syeyoung.dungeonsguide.events.PlayerInteractEntityEvent; import kr.syeyoung.dungeonsguide.features.FeatureRegistry; import kr.syeyoung.dungeonsguide.roomprocessor.GeneralRoomProcessor; @@ -51,7 +52,6 @@ import net.minecraft.util.IChatComponent; import net.minecraftforge.client.event.GuiScreenEvent; import net.minecraftforge.event.entity.living.LivingEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; -import net.minecraftforge.fml.common.gameevent.InputEvent; import org.apache.commons.codec.binary.Base64; import java.io.ByteArrayInputStream; @@ -358,8 +358,8 @@ public class RoomProcessorBombDefuseSolver extends GeneralRoomProcessor { } @Override - public void onKeyPress(InputEvent.KeyInputEvent keyInputEvent) { - super.onKeyPress(keyInputEvent); + public void onKeybindPress(KeyBindPressedEvent keyInputEvent) { + super.onKeybindPress(keyInputEvent); if (bugged) return; BlockPos player = Minecraft.getMinecraft().thePlayer.getPosition(); @@ -367,12 +367,12 @@ public class RoomProcessorBombDefuseSolver extends GeneralRoomProcessor { for (ChamberSet ch:chambers) { if (ch.getLeft() != null && ch.getLeft().getProcessor() != null) { if (ch.getLeft().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { - ch.getLeft().getProcessor().onKeyPress(keyInputEvent); + ch.getLeft().getProcessor().onKeybindPress(keyInputEvent); } } if (ch.getRight() != null && ch.getRight().getProcessor() != null) { if (ch.getRight().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { - ch.getRight().getProcessor().onKeyPress(keyInputEvent); + ch.getRight().getProcessor().onKeybindPress(keyInputEvent); } } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/GeneralDefuseChamberProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/GeneralDefuseChamberProcessor.java index 823e322b..3f8172d2 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/GeneralDefuseChamberProcessor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/GeneralDefuseChamberProcessor.java @@ -20,22 +20,22 @@ package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers; import kr.syeyoung.dungeonsguide.Keybinds; import kr.syeyoung.dungeonsguide.events.BlockUpdateEvent; +import kr.syeyoung.dungeonsguide.events.KeyBindPressedEvent; import kr.syeyoung.dungeonsguide.events.PlayerInteractEntityEvent; +import kr.syeyoung.dungeonsguide.features.FeatureRegistry; import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; import lombok.Getter; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.item.EntityArmorStand; +import net.minecraft.client.settings.GameSettings; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.IChatComponent; import net.minecraftforge.client.event.GuiScreenEvent; import net.minecraftforge.event.entity.living.LivingDeathEvent; import net.minecraftforge.event.entity.living.LivingEvent; -import net.minecraftforge.event.entity.player.EntityInteractEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; -import net.minecraftforge.fml.common.gameevent.InputEvent; import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL14; @@ -108,7 +108,7 @@ public abstract class GeneralDefuseChamberProcessor implements ChamberProcessor protected void drawPressKey() { FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); - String str = "Press "+ Keyboard.getKeyName(Keybinds.sendBombdefuse.getKeyCode()) + " to save and send solution"; + String str = "Press "+ GameSettings.getKeyDisplayString(FeatureRegistry.SOLVER_BOMBDEFUSE.<Integer>getParameter("key").getValue()) + " to save and send solution"; GlStateManager.enableBlend(); GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); @@ -116,8 +116,8 @@ public abstract class GeneralDefuseChamberProcessor implements ChamberProcessor } @Override - public void onKeyPress(InputEvent.KeyInputEvent keyInputEvent) { - if (Keybinds.sendBombdefuse.isKeyDown()) { + public void onKeybindPress(KeyBindPressedEvent keyInputEvent) { + if (keyInputEvent.getKey() == FeatureRegistry.SOLVER_BOMBDEFUSE.<Integer>getParameter("key").getValue()) { if (!getChamber().isWithinAbsolute(Minecraft.getMinecraft().thePlayer.getPosition())) { return; } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/color/ColorRightProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/color/ColorRightProcessor.java index 2350c38b..e267859d 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/color/ColorRightProcessor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/color/ColorRightProcessor.java @@ -21,11 +21,13 @@ package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.color; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; import kr.syeyoung.dungeonsguide.Keybinds; +import kr.syeyoung.dungeonsguide.features.FeatureRegistry; import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.BDChamber; import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.GeneralDefuseChamberProcessor; import kr.syeyoung.dungeonsguide.utils.RenderUtils; import net.minecraft.block.Block; +import net.minecraft.client.settings.GameSettings; import net.minecraft.entity.item.EntityArmorStand; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -69,7 +71,7 @@ public class ColorRightProcessor extends GeneralDefuseChamberProcessor { @Override public void drawWorld(float partialTicks) { super.drawWorld(partialTicks); - RenderUtils.drawTextAtWorld(answer == -1 ? "Press "+ Keyboard.getKeyName(Keybinds.sendBombdefuse.getKeyCode())+" to request solution" : "" , center.getX()+ 0.5f, center.getY(), center.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); + RenderUtils.drawTextAtWorld(answer == -1 ? "Press "+ GameSettings.getKeyDisplayString(FeatureRegistry.SOLVER_BOMBDEFUSE.<Integer>getParameter("key").getValue()) +" to request solution" : "" , center.getX()+ 0.5f, center.getY(), center.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); RenderUtils.drawTextAtWorld( colors.get((int) c1b), b1.getX()+ 0.5f, b1.getY()+0.6f, b1.getZ()+ 0.5f,c1b == b1b ? 0xFF00FF00 : 0xFFFF0000, 0.03F, false, false, partialTicks); RenderUtils.drawTextAtWorld( colors.get((int) c2b), b2.getX()+ 0.5f, b2.getY()+0.6f, b2.getZ()+ 0.5f,c2b == b2b ? 0xFF00FF00 : 0xFFFF0000, 0.03F, false, false, partialTicks); RenderUtils.drawTextAtWorld( colors.get((int) c3b), b3.getX()+ 0.5f, b3.getY()+0.6f, b3.getZ()+ 0.5f,c3b == b3b ? 0xFF00FF00 : 0xFFFF0000, 0.03F, false, false, partialTicks); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/maze/MazeLeftProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/maze/MazeLeftProcessor.java index 4b998144..77c8134b 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/maze/MazeLeftProcessor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/maze/MazeLeftProcessor.java @@ -19,6 +19,7 @@ package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.maze; import kr.syeyoung.dungeonsguide.Keybinds; +import kr.syeyoung.dungeonsguide.features.FeatureRegistry; import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.BDChamber; import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.GeneralDefuseChamberProcessor; @@ -28,6 +29,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.settings.GameSettings; import net.minecraft.init.Blocks; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.BlockPos; @@ -63,7 +65,7 @@ public class MazeLeftProcessor extends GeneralDefuseChamberProcessor { FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); - String str = "Press "+ Keyboard.getKeyName(Keybinds.sendBombdefuse.getKeyCode()) + " to request open "+b.getLocalizedName(); + String str = "Press "+ GameSettings.getKeyDisplayString(FeatureRegistry.SOLVER_BOMBDEFUSE.<Integer>getParameter("key").getValue()) + " to request open "+b.getLocalizedName(); GlStateManager.enableBlend(); GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/GeneralBossfightProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/GeneralBossfightProcessor.java index 1d297a0d..e8ed8981 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/GeneralBossfightProcessor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/GeneralBossfightProcessor.java @@ -19,17 +19,15 @@ package kr.syeyoung.dungeonsguide.roomprocessor.bossfight; import kr.syeyoung.dungeonsguide.events.BlockUpdateEvent; +import kr.syeyoung.dungeonsguide.events.KeyBindPressedEvent; import kr.syeyoung.dungeonsguide.events.PlayerInteractEntityEvent; import lombok.*; -import net.minecraft.entity.boss.BossStatus; -import net.minecraft.entity.boss.EntityDragon; import net.minecraft.util.IChatComponent; import net.minecraft.world.World; import net.minecraftforge.client.event.GuiScreenEvent; import net.minecraftforge.event.entity.living.LivingDeathEvent; import net.minecraftforge.event.entity.living.LivingEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; -import net.minecraftforge.fml.common.gameevent.InputEvent; import java.util.*; @@ -116,7 +114,7 @@ public abstract class GeneralBossfightProcessor implements BossfightProcessor { } @Override - public void onKeyPress(InputEvent.KeyInputEvent keyInputEvent) { + public void onKeybindPress(KeyBindPressedEvent keyInputEvent) { } |