aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr/syeyoung
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/kr/syeyoung')
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonNPC.java88
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/eventlistener/FeatureListener.java15
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java3
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureMechanicBrowse.java190
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditFairySoul.java2
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditNPC.java105
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditRegistry.java1
7 files changed, 374 insertions, 30 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonNPC.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonNPC.java
new file mode 100755
index 00000000..086f3d11
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonNPC.java
@@ -0,0 +1,88 @@
+package kr.syeyoung.dungeonsguide.dungeon.mechanics;
+
+import com.google.common.collect.Sets;
+import kr.syeyoung.dungeonsguide.dungeon.actions.Action;
+import kr.syeyoung.dungeonsguide.dungeon.actions.ActionChangeState;
+import kr.syeyoung.dungeonsguide.dungeon.actions.ActionInteract;
+import kr.syeyoung.dungeonsguide.dungeon.actions.ActionMove;
+import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint;
+import kr.syeyoung.dungeonsguide.dungeon.mechanics.predicates.PredicateArmorStand;
+import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom;
+import kr.syeyoung.dungeonsguide.utils.RenderUtils;
+import lombok.Data;
+import net.minecraft.util.BlockPos;
+
+import java.awt.*;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+@Data
+public class DungeonNPC implements DungeonMechanic {
+ private OffsetPoint secretPoint = new OffsetPoint(0,0,0);
+ private List<String> preRequisite = new ArrayList<String>();
+
+
+ @Override
+ public Set<Action> getAction(String state, DungeonRoom dungeonRoom) {
+ if (!"navigate".equalsIgnoreCase(state)) throw new IllegalArgumentException(state+" is not valid state for secret");
+ Set<Action> base;
+ Set<Action> preRequisites = base = new HashSet<Action>();
+ {
+ ActionInteract actionClick= new ActionInteract(secretPoint);
+ actionClick.setPredicate(PredicateArmorStand.INSTANCE);
+ actionClick.setRadius(3);
+ preRequisites.add(actionClick);
+ preRequisites = actionClick.getPreRequisite();
+ }
+ {
+ ActionMove actionMove = new ActionMove(secretPoint);
+ preRequisites.add(actionMove);
+ preRequisites = actionMove.getPreRequisite();
+ }
+ {
+ for (String str : preRequisite) {
+ if (str.isEmpty()) continue;
+ ActionChangeState actionChangeState = new ActionChangeState(str.split(":")[0], str.split(":")[1]);
+ preRequisites.add(actionChangeState);
+ }
+ }
+ return base;
+ }
+
+ @Override
+ public void highlight(Color color, String name, DungeonRoom dungeonRoom, float partialTicks) {
+ BlockPos pos = getSecretPoint().getBlockPos(dungeonRoom);
+ RenderUtils.highlightBlock(pos, color,partialTicks);
+ RenderUtils.drawTextAtWorld("F-"+name, pos.getX() +0.5f, pos.getY()+0.375f, pos.getZ()+0.5f, 0xFFFFFFFF, 0.03f, false, true, partialTicks);
+ RenderUtils.drawTextAtWorld(getCurrentState(dungeonRoom), pos.getX() +0.5f, pos.getY()+0f, pos.getZ()+0.5f, 0xFFFFFFFF, 0.03f, false, true, partialTicks);
+ }
+
+
+ public DungeonNPC clone() throws CloneNotSupportedException {
+ DungeonNPC dungeonSecret = new DungeonNPC();
+ dungeonSecret.secretPoint = (OffsetPoint) secretPoint.clone();
+ dungeonSecret.preRequisite = new ArrayList<String>(preRequisite);
+ return dungeonSecret;
+ }
+
+
+ @Override
+ public String getCurrentState(DungeonRoom dungeonRoom) {
+ return "no-state";
+ }
+
+ @Override
+ public Set<String> getPossibleStates(DungeonRoom dungeonRoom) {
+ return Sets.newHashSet("navigate");
+ }
+ @Override
+ public Set<String> getTotalPossibleStates(DungeonRoom dungeonRoom) {
+ return Sets.newHashSet("no-state","navigate");
+ }
+ @Override
+ public OffsetPoint getRepresentingPoint() {
+ return secretPoint;
+ }
+}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/FeatureListener.java b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/FeatureListener.java
index 3e3b59d8..f9e0ba5a 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/FeatureListener.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/FeatureListener.java
@@ -162,6 +162,21 @@ public class FeatureListener {
}
@SubscribeEvent
+ public void onGuiEvent(GuiScreenEvent.MouseInputEvent.Pre input) {
+ try {
+ SkyblockStatus skyblockStatus = e.getDungeonsGuide().getSkyblockStatus();
+ if (!skyblockStatus.isOnSkyblock()) return;
+
+ for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) {
+ if (abstractFeature instanceof GuiClickListener) {
+ ((GuiClickListener) abstractFeature).onMouseInput(input);
+ }
+ }
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ }
+ @SubscribeEvent
public void onSkyblockJoin(SkyblockJoinedEvent joinedEvent) {
try {
for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) {
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java
index 8220bb19..d34e7eee 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java
@@ -9,6 +9,7 @@ import kr.syeyoung.dungeonsguide.features.impl.etc.FeatureCooldownCounter;
import kr.syeyoung.dungeonsguide.features.impl.etc.FeatureDisableMessage;
import kr.syeyoung.dungeonsguide.features.impl.etc.FeatureTooltipDungeonStat;
import kr.syeyoung.dungeonsguide.features.impl.etc.FeatureTooltipPrice;
+import kr.syeyoung.dungeonsguide.features.impl.secret.FeatureMechanicBrowse;
import lombok.Getter;
import java.util.ArrayList;
@@ -86,4 +87,6 @@ public class FeatureRegistry {
public static final SimpleFeature DUNGEON_INTERMODCOMM = register(new SimpleFeature("Dungeon", "Communicate With Other's Dungeons Guide", "Sends total secret in the room to others\nSo that they can use the data to calculate total secret in dungeon run\n\nThis automates player chatting action, (chatting data) Thus it might be against hypixel's rules.\nBut mods like auto-gg which also automate player action and is kinda allowed mod exist so I'm leaving this feature.\nThis option is use-at-your-risk and you'll be responsible for ban if you somehow get banned because of this feature\n(Although it is not likely to happen)\nDefaults to off", "dungeon.intermodcomm", false));
public static final FeatureDungeonMap DUNGEON_MAP = register(new FeatureDungeonMap());
+ public static final FeatureMechanicBrowse SECRET_BROWSE = register(new FeatureMechanicBrowse());
+
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureMechanicBrowse.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureMechanicBrowse.java
index daa3c0e8..95ac96e2 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureMechanicBrowse.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureMechanicBrowse.java
@@ -1,6 +1,9 @@
package kr.syeyoung.dungeonsguide.features.impl.secret;
+import com.google.common.collect.Lists;
import kr.syeyoung.dungeonsguide.SkyblockStatus;
+import kr.syeyoung.dungeonsguide.config.guiconfig.GuiConfig;
+import kr.syeyoung.dungeonsguide.config.guiconfig.GuiGuiLocationConfig;
import kr.syeyoung.dungeonsguide.dungeon.DungeonContext;
import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute;
import kr.syeyoung.dungeonsguide.dungeon.mechanics.*;
@@ -9,6 +12,11 @@ import kr.syeyoung.dungeonsguide.e;
import kr.syeyoung.dungeonsguide.features.GuiFeature;
import kr.syeyoung.dungeonsguide.features.listener.GuiClickListener;
import kr.syeyoung.dungeonsguide.features.listener.GuiPostRenderListener;
+import kr.syeyoung.dungeonsguide.features.listener.WorldRenderListener;
+import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonAddSet;
+import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonParameterEdit;
+import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonRoomEdit;
+import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonValueEdit;
import kr.syeyoung.dungeonsguide.roomprocessor.GeneralRoomProcessor;
import kr.syeyoung.dungeonsguide.roomprocessor.RoomProcessor;
import net.minecraft.client.Minecraft;
@@ -17,6 +25,7 @@ import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.util.MathHelper;
import net.minecraftforge.client.event.GuiScreenEvent;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
@@ -24,10 +33,12 @@ import org.lwjgl.opengl.GL11;
import java.awt.*;
import java.util.List;
import java.util.ArrayList;
+import java.util.Map;
+import java.util.Set;
-public class FeatureMechanicBrowse extends GuiFeature implements GuiPostRenderListener, GuiClickListener {
+public class FeatureMechanicBrowse extends GuiFeature implements GuiPostRenderListener, GuiClickListener, WorldRenderListener {
- protected FeatureMechanicBrowse(String category, String name, String description, String key, boolean keepRatio, int width, int height) {
+ public FeatureMechanicBrowse() {
super("secret","Mechanic(Secret) Browser", "Browse and Pathfind secrets and mechanics in the current room", "secret.mechanicbrowse", false, 100, 300);
}
@@ -59,7 +70,7 @@ public class FeatureMechanicBrowse extends GuiFeature implements GuiPostRenderLi
ActionRoute route = grp.getPath();
fr.drawString(route.getMechanic()+" -> "+route.getState(), fr.getStringWidth("Selected: ") + 2,2, 0xFFFFFF00);
}
- fr.drawString("Press T to browse mechanic", 2, fr.FONT_HEIGHT + 5, 0xFFAAAAAA);
+ fr.drawString("Open any gui to browse", 2, fr.FONT_HEIGHT + 5, 0xFFAAAAAA);
}
@Override
@@ -71,11 +82,18 @@ public class FeatureMechanicBrowse extends GuiFeature implements GuiPostRenderLi
Gui.drawRect(1, 1, feature.width - 1, fr.FONT_HEIGHT + 3, 0xFF262626);
fr.drawString("Selected: ", 2,2, 0xFFAAAAAA);
fr.drawString("Nothing", fr.getStringWidth("Selected: ") + 2,2, 0xFFAA0000);
- fr.drawString("Press T to browse mechanic", 2, fr.FONT_HEIGHT + 5, 0xFFAAAAAA);
+ fr.drawString("Open any gui to browse", 2, fr.FONT_HEIGHT + 5, 0xFFAAAAAA);
}
@Override
public void onGuiPostRender(GuiScreenEvent.DrawScreenEvent.Post rendered) {
+ if (Minecraft.getMinecraft().currentScreen instanceof GuiGuiLocationConfig
+ || Minecraft.getMinecraft().currentScreen instanceof GuiConfig
+ || Minecraft.getMinecraft().currentScreen instanceof GuiDungeonRoomEdit
+ || Minecraft.getMinecraft().currentScreen instanceof GuiDungeonAddSet
+ || Minecraft.getMinecraft().currentScreen instanceof GuiDungeonParameterEdit
+ || Minecraft.getMinecraft().currentScreen instanceof GuiDungeonValueEdit) return;
+
if (!skyblockStatus.isOnDungeon()) return;
if (skyblockStatus.getContext() == null || !skyblockStatus.getContext().getMapProcessor().isInitialized()) return;
DungeonContext context = skyblockStatus.getContext();
@@ -85,6 +103,11 @@ public class FeatureMechanicBrowse extends GuiFeature implements GuiPostRenderLi
DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt);
if (dungeonRoom == null) return;
if (!(dungeonRoom.getRoomProcessor() instanceof GeneralRoomProcessor)) return;
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ int width = scaledResolution.getScaledWidth();
+ int height = scaledResolution.getScaledHeight();
+ int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
+ int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
GeneralRoomProcessor grp = (GeneralRoomProcessor) dungeonRoom.getRoomProcessor();
@@ -101,11 +124,53 @@ public class FeatureMechanicBrowse extends GuiFeature implements GuiPostRenderLi
ActionRoute route = grp.getPath();
fr.drawString(route.getMechanic()+" -> "+route.getState(), fr.getStringWidth("Selected: ") + 2,2, 0xFFFFFF00);
}
- clip(new ScaledResolution(Minecraft.getMinecraft()), 0, fr.FONT_HEIGHT + 4, feature.width, fr.FONT_HEIGHT * 10 + 4);
+ clip(new ScaledResolution(Minecraft.getMinecraft()), feature.x, feature.y + fr.FONT_HEIGHT + 4, feature.width , fr.FONT_HEIGHT * 10 + 4);
+ GL11.glEnable(GL11.GL_SCISSOR_TEST);
+ GlStateManager.translate(0, fr.FONT_HEIGHT + 4, 0);
+ Gui.drawRect(0, 0, feature.width, fr.FONT_HEIGHT * 9 + 4, 0xFF444444);
+ Gui.drawRect(1, 1, feature.width - 1, fr.FONT_HEIGHT * 9 + 3, 0xFF262626);
+ GlStateManager.translate(0, -dy, 0);
+
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(2,2, 0);
+ setupMechanics();
+ for (int i = 0; i < sortedMechanics.size(); i++) {
+ Object obj = sortedMechanics.get(i);
+ if (selected == i) {
+ Gui.drawRect(-1, i * fr.FONT_HEIGHT, feature.width - 3, i * fr.FONT_HEIGHT + fr.FONT_HEIGHT - 1, 0xFF444444);
+ } else if (new Rectangle(feature.x, feature.y + fr.FONT_HEIGHT + 6 - dy + i * fr.FONT_HEIGHT, feature.width, fr.FONT_HEIGHT).contains(mouseX, mouseY)) {
+ Gui.drawRect(-1, i * fr.FONT_HEIGHT, feature.width - 3, i * fr.FONT_HEIGHT + fr.FONT_HEIGHT - 1, 0xFF555555);
+ }
+ if (obj instanceof DungeonMechanic) {
+ String name = sortedMechanicsName.get(i);
+ fr.drawString(name, 3, i * fr.FONT_HEIGHT, 0xFFFFFF00);
+ fr.drawString(" ("+ ((DungeonMechanic) obj).getCurrentState(dungeonRoom) +", "+
+ (((DungeonMechanic) obj).getRepresentingPoint() != null ?
+ String.format("%.1f", MathHelper.sqrt_double(((DungeonMechanic) obj).getRepresentingPoint().getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()))) : "")
+ +"m)",fr.getStringWidth(name) + 3, i * fr.FONT_HEIGHT, 0xFFAAAAAA);
+ } else {
+ Gui.drawRect(-1, i * fr.FONT_HEIGHT, feature.width - 3, i * fr.FONT_HEIGHT + fr.FONT_HEIGHT - 1, 0xFF444444);
+ fr.drawString((String)obj, 3, i * fr.FONT_HEIGHT, 0xFFEEEEEE);
+ }
+ }
+ GlStateManager.popMatrix();;
- Gui.drawRect(0, fr.FONT_HEIGHT + 4, feature.width, fr.FONT_HEIGHT * 10 + 4, 0xFF444444);
- Gui.drawRect(1, fr.FONT_HEIGHT + 5, feature.width - 1, fr.FONT_HEIGHT * 10 + 3, 0xFF262626);
+ clip(new ScaledResolution(Minecraft.getMinecraft()), feature.x + feature.width, feature.y + fr.FONT_HEIGHT + 4, feature.width, fr.FONT_HEIGHT * 10 + 4);
+ if (selected != -1) {
+ GlStateManager.translate(feature.width, selected * fr.FONT_HEIGHT, 0);
+ Gui.drawRect(0, 0, feature.width, fr.FONT_HEIGHT * possibleStates.size() + 4, 0xFF444444);
+ Gui.drawRect(-1, 1, feature.width - 1, fr.FONT_HEIGHT * possibleStates.size() + 3, 0xFF262626);
+ GlStateManager.translate(2,2, 0);
+ Point popupStart = new Point(feature.x + feature.width, (selected + 1) * fr.FONT_HEIGHT +6 + feature.y - dy + 2);
+ for (int i = 0; i < possibleStates.size(); i++) {
+ if (new Rectangle(feature.x + feature.width, popupStart.y + i * fr.FONT_HEIGHT, feature.width, fr.FONT_HEIGHT).contains(mouseX, mouseY)) {
+ Gui.drawRect(-2, i * fr.FONT_HEIGHT, feature.width - 3, i * fr.FONT_HEIGHT + fr.FONT_HEIGHT - 1, 0xFF555555);
+ }
+ fr.drawString(possibleStates.get(i), 0, i * fr.FONT_HEIGHT, 0xFFFFFFFF);
+ }
+ }
+ GL11.glDisable(GL11.GL_SCISSOR_TEST);
}
private void clip(ScaledResolution resolution, int x, int y, int width, int height) {
@@ -116,9 +181,12 @@ public class FeatureMechanicBrowse extends GuiFeature implements GuiPostRenderLi
private int dy = 0;
private int selected = -1;
private int selectedState = -1;
+ private List<String> possibleStates = new ArrayList<String>();
private List<Object> sortedMechanics = new ArrayList<Object>();
+ private List<String> sortedMechanicsName = new ArrayList<String>();
private void setupMechanics() {
sortedMechanics.clear();
+ sortedMechanicsName.clear();
if (!skyblockStatus.isOnDungeon()) return;
if (skyblockStatus.getContext() == null || !skyblockStatus.getContext().getMapProcessor().isInitialized()) return;
@@ -131,44 +199,64 @@ public class FeatureMechanicBrowse extends GuiFeature implements GuiPostRenderLi
if (!(dungeonRoom.getRoomProcessor() instanceof GeneralRoomProcessor)) return;
boolean found = false;
- for (DungeonMechanic value : ((GeneralRoomProcessor) dungeonRoom.getRoomProcessor()).getDungeonRoom().getDungeonRoomInfo().getMechanics().values()) {
- if (value instanceof DungeonDoor) {
+ for (Map.Entry<String, DungeonMechanic> value : ((GeneralRoomProcessor) dungeonRoom.getRoomProcessor()).getDungeonRoom().getDungeonRoomInfo().getMechanics().entrySet()) {
+ if (value.getValue() instanceof DungeonDoor) {
if (!found) {
sortedMechanics.add("Fairy Souls");
+ sortedMechanicsName.add("");
found = true;
}
- sortedMechanics.add(value);
+ sortedMechanics.add(value.getValue());
+ sortedMechanicsName.add(value.getKey());
}
}
found = false;
- for (DungeonMechanic value : ((GeneralRoomProcessor) dungeonRoom.getRoomProcessor()).getDungeonRoom().getDungeonRoomInfo().getMechanics().values()) {
- if (value instanceof DungeonSecret) {
+ for (Map.Entry<String, DungeonMechanic> value : ((GeneralRoomProcessor) dungeonRoom.getRoomProcessor()).getDungeonRoom().getDungeonRoomInfo().getMechanics().entrySet()) {
+ if (value.getValue() instanceof DungeonSecret) {
if (!found) {
sortedMechanics.add("Secrets");
+ sortedMechanicsName.add("");
found = true;
}
- sortedMechanics.add(value);
+ sortedMechanics.add(value.getValue());
+ sortedMechanicsName.add(value.getKey());
}
}
found = false;
- for (DungeonMechanic value : ((GeneralRoomProcessor) dungeonRoom.getRoomProcessor()).getDungeonRoom().getDungeonRoomInfo().getMechanics().values()) {
- if (value instanceof DungeonTomb) {
+ for (Map.Entry<String, DungeonMechanic> value : ((GeneralRoomProcessor) dungeonRoom.getRoomProcessor()).getDungeonRoom().getDungeonRoomInfo().getMechanics().entrySet()) {
+ if (value.getValue() instanceof DungeonTomb) {
if (!found) {
sortedMechanics.add("Crypts");
+ sortedMechanicsName.add("");
found = true;
}
- sortedMechanics.add(value);
+ sortedMechanics.add(value.getValue());
+ sortedMechanicsName.add(value.getKey());
}
}
found = false;
- for (DungeonMechanic value : ((GeneralRoomProcessor) dungeonRoom.getRoomProcessor()).getDungeonRoom().getDungeonRoomInfo().getMechanics().values()) {
- if (value instanceof DungeonDoor || value instanceof DungeonBreakableWall || value instanceof DungeonLever
- || value instanceof DungeonOnewayDoor || value instanceof DungeonOnewayLever || value instanceof DungeonPressurePlate) {
+ for (Map.Entry<String, DungeonMechanic> value : ((GeneralRoomProcessor) dungeonRoom.getRoomProcessor()).getDungeonRoom().getDungeonRoomInfo().getMechanics().entrySet()) {
+ if (value.getValue() instanceof DungeonNPC) {
if (!found) {
- sortedMechanics.add("Walls & Doors & Levers & Pressure Plates");
+ sortedMechanics.add("NPC");
+ sortedMechanicsName.add("");
found = true;
}
- sortedMechanics.add(value);
+ sortedMechanics.add(value.getValue());
+ sortedMechanicsName.add(value.getKey());
+ }
+ }
+ found = false;
+ for (Map.Entry<String, DungeonMechanic> value : ((GeneralRoomProcessor) dungeonRoom.getRoomProcessor()).getDungeonRoom().getDungeonRoomInfo().getMechanics().entrySet()) {
+ if (value.getValue() instanceof DungeonDoor || value.getValue() instanceof DungeonBreakableWall || value.getValue() instanceof DungeonLever
+ || value.getValue() instanceof DungeonOnewayDoor || value.getValue() instanceof DungeonOnewayLever || value.getValue() instanceof DungeonPressurePlate) {
+ if (!found) {
+ sortedMechanics.add("ETC");
+ sortedMechanicsName.add("");
+ found = true;
+ }
+ sortedMechanics.add(value.getValue());
+ sortedMechanicsName.add(value.getKey());
}
}
}
@@ -193,26 +281,70 @@ public class FeatureMechanicBrowse extends GuiFeature implements GuiPostRenderLi
Rectangle feature = getFeatureRect();
FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
- Point popupStart = new Point(feature.x + feature.width, (selected - dy) * fr.FONT_HEIGHT + 7 + feature.y);
+ Point popupStart = new Point(feature.x + feature.width, (selected + 1) * fr.FONT_HEIGHT +6 + feature.y - dy);
if (feature.contains(mouseX, mouseY)) {
mouseInputEvent.setCanceled(true);
int wheel = Mouse.getDWheel();
- if (wheel > 0) dy ++;
- else if (wheel < 0) dy --;
+ if (wheel > 0) dy += fr.FONT_HEIGHT;
+ else if (wheel < 0) dy -= fr.FONT_HEIGHT;
+ if (dy < 0) dy = 0;
if (Mouse.getEventButton() != -1) {
- int yDiff = mouseY - feature.y - fr.FONT_HEIGHT - 7;
- selected = yDiff / fr.FONT_HEIGHT + dy;
+ int yDiff = mouseY + dy - feature.y - fr.FONT_HEIGHT - 6;
+ selected = yDiff / fr.FONT_HEIGHT;
+
+ if (selected < 0) selected = -1;
+ if (selected >= sortedMechanics.size()) selected = -1;
+ if (selected == -1) {
+ possibleStates.clear();
+ } else if (sortedMechanics.get(selected) instanceof DungeonMechanic){
+ possibleStates = Lists.newArrayList(((DungeonMechanic) sortedMechanics.get(selected)).getPossibleStates(dungeonRoom));
+ } else {
+ possibleStates.clear();
+ selected = -1;
+ selectedState = -1;
+ }
}
- } else if (sortedMechanics.get(selected) instanceof DungeonMechanic &&
- new Rectangle(popupStart, new Dimension(feature.width, ((DungeonMechanic) sortedMechanics.get(selected)).getPossibleStates(dungeonRoom).size() * fr.FONT_HEIGHT + 6)).contains(mouseX, mouseY)) {
+ } else if (selected != -1 && sortedMechanics.get(selected) instanceof DungeonMechanic &&
+ new Rectangle(popupStart, new Dimension(feature.width, ((DungeonMechanic) sortedMechanics.get(selected)).getPossibleStates(dungeonRoom).size() * fr.FONT_HEIGHT)).contains(mouseX, mouseY)) {
mouseInputEvent.setCanceled(true);
if (Mouse.getEventButton() != -1) {
int yDiff = mouseY - popupStart.y - 2;
- selected = yDiff / fr.FONT_HEIGHT + dy;
+ int preSelectedState = yDiff / fr.FONT_HEIGHT ;
+ if (preSelectedState < 0) preSelectedState = -1;
+ if (preSelectedState >= possibleStates.size()) preSelectedState =
+ possibleStates.size() - 1;
+ if (preSelectedState == selectedState && preSelectedState != -1) {
+ ((GeneralRoomProcessor) dungeonRoom.getRoomProcessor()).pathfind(sortedMechanicsName.get(selected),
+ possibleStates.get(selectedState));
+ }
+ selectedState = preSelectedState;
}
+ } else if (Mouse.getEventButton() != -1){
+ possibleStates.clear();
+ selectedState = -1;
+ selected = -1;
+ }
+ }
+
+ @Override
+ public void drawWorld(float partialTicks) {
+ if (!skyblockStatus.isOnDungeon()) return;
+ if (skyblockStatus.getContext() == null || !skyblockStatus.getContext().getMapProcessor().isInitialized()) return;
+ DungeonContext context = skyblockStatus.getContext();
+
+ EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer;
+ Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition());
+ DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt);
+ if (dungeonRoom == null) return;
+ if (!(dungeonRoom.getRoomProcessor() instanceof GeneralRoomProcessor)) return;
+ if (selected != -1) {
+ ((DungeonMechanic)sortedMechanics.get(selected)).highlight(new Color(0,255,255,50), sortedMechanicsName.get(selected) +" ("+(((DungeonMechanic)
+ sortedMechanics.get(selected)).getRepresentingPoint() != null ?
+ String.format("%.1f", MathHelper.sqrt_double(((DungeonMechanic) sortedMechanics.get(selected)).getRepresentingPoint().getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()))) : "")
+ +"m)", dungeonRoom, partialTicks);
}
}
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditFairySoul.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditFairySoul.java
index 70da3b55..d16fb5bc 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditFairySoul.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditFairySoul.java
@@ -15,7 +15,7 @@ import java.awt.*;
import java.util.Arrays;
import java.util.Collections;
-public class ValueEditFairySoul extends MPanel implements ValueEdit<DungeonSecret> {
+public class ValueEditFairySoul extends MPanel implements ValueEdit<DungeonFairySoul> {
private Parameter parameter;
// scroll pane
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditNPC.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditNPC.java
new file mode 100755
index 00000000..322bfad5
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditNPC.java
@@ -0,0 +1,105 @@
+package kr.syeyoung.dungeonsguide.roomedit.mechanicedit;
+
+import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint;
+import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonFairySoul;
+import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonNPC;
+import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonSecret;
+import kr.syeyoung.dungeonsguide.gui.MPanel;
+import kr.syeyoung.dungeonsguide.gui.elements.MLabel;
+import kr.syeyoung.dungeonsguide.gui.elements.MLabelAndElement;
+import kr.syeyoung.dungeonsguide.gui.elements.MTextField;
+import kr.syeyoung.dungeonsguide.gui.elements.MValue;
+import kr.syeyoung.dungeonsguide.roomedit.EditingContext;
+import kr.syeyoung.dungeonsguide.roomedit.Parameter;
+import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEdit;
+import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditCreator;
+import kr.syeyoung.dungeonsguide.utils.TextUtils;
+
+import java.awt.*;
+import java.util.Arrays;
+import java.util.Collections;
+
+public class ValueEditNPC extends MPanel implements ValueEdit<DungeonNPC> {
+ private Parameter parameter;
+
+ // scroll pane
+ // just create
+ // add set
+ private DungeonNPC dungeonSecret;
+
+ private MLabel label;
+ private MValue<OffsetPoint> value;
+ private MTextField preRequisite;
+ private MLabelAndElement preRequisite2;
+
+ public ValueEditNPC(final Parameter parameter2) {
+ this.parameter = parameter2;
+ this.dungeonSecret = (DungeonNPC) parameter2.getNewData();
+
+
+ label = new MLabel();
+ label.setText("FairySoul Point");
+ label.setAlignment(MLabel.Alignment.LEFT);
+ add(label);
+
+ value = new MValue(dungeonSecret.getSecretPoint(), Collections.emptyList());
+ add(value);
+
+ preRequisite = new MTextField() {
+ @Override
+ public void edit(String str) {
+ dungeonSecret.setPreRequisite(Arrays.asList(str.split(",")));
+ }
+ };
+ preRequisite.setText(TextUtils.join(dungeonSecret.getPreRequisite(), ","));
+ preRequisite2 = new MLabelAndElement("Req.",preRequisite);
+ preRequisite2.setBounds(new Rectangle(0,40,getBounds().width,20));
+ add(preRequisite2);
+ }
+
+ @Override
+ public void onBoundsUpdate() {
+ label.setBounds(new Rectangle(0,0,getBounds().width, 20));
+ value.setBounds(new Rectangle(0,20,getBounds().width, 20));
+ preRequisite2.setBounds(new Rectangle(0,40,getBounds().width,20));
+ }
+
+ @Override
+ public void setParameter(Parameter parameter) {
+ this.parameter = parameter;
+ }
+
+ @Override
+ public void renderWorld(float partialTicks) {
+ dungeonSecret.highlight(new Color(0,255,0,50), parameter.getName(), EditingContext.getEditingContext().getRoom(), partialTicks);
+ }
+
+ @Override
+ public void resize(int parentWidth, int parentHeight) {
+ this.setBounds(new Rectangle(0,0,parentWidth, parentHeight));
+ }
+
+ public static class Generator implements ValueEditCreator<ValueEditNPC> {
+
+ @Override
+ public ValueEditNPC createValueEdit(Parameter parameter) {
+ return new ValueEditNPC(parameter);
+ }
+
+ @Override
+ public Object createDefaultValue(Parameter parameter) {
+ return new DungeonNPC();
+ }
+
+ @Override
+ public Object cloneObj(Object object) {
+ try {
+ return ((DungeonNPC)object).clone();
+ } catch (CloneNotSupportedException e) {
+ e.printStackTrace();
+ }
+ assert false;
+ return null;
+ }
+ }
+}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditRegistry.java
index a19dbb0c..beb5a10f 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditRegistry.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditRegistry.java
@@ -37,6 +37,7 @@ public class ValueEditRegistry {
valueEditMap.put(DungeonSecret.class.getName(), new ValueEditSecret.Generator());
valueEditMap.put(DungeonFairySoul.class.getName(), new ValueEditFairySoul.Generator());
+ valueEditMap.put(ValueEditNPC.class.getName(), new ValueEditNPC.Generator());
valueEditMap.put(DungeonTomb.class.getName(), new ValueEditTomb.Generator());
valueEditMap.put(DungeonBreakableWall.class.getName(), new ValueEditBreakableWall.Generator());