diff options
Diffstat (limited to 'src/main')
11 files changed, 420 insertions, 104 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java index 9a3c42bc..05eb09e9 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java @@ -113,9 +113,10 @@ public class DungeonRoom { if (roomMatcher == null) roomMatcher = new RoomMatcher(this); DungeonRoomInfo dungeonRoomInfo = roomMatcher.match(); - if (dungeonRoomInfo == null) + if (dungeonRoomInfo == null) { dungeonRoomInfo = roomMatcher.createNew(); - + if (color == 18) dungeonRoomInfo.setProcessorId("bossroom"); + } this.dungeonRoomInfo = dungeonRoomInfo; totalSecrets = dungeonRoomInfo.getTotalSecrets(); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java index 9e630601..ef5e4271 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java @@ -67,6 +67,7 @@ public class FeatureRegistry { public static final FeatureCopyMessages ETC_COPY_MSG = register(new FeatureCopyMessages()); + public static final FeatureWarningOnPortal BOSSFIGHT_WARNING_ON_PORTAL = register(new FeatureWarningOnPortal()); public static final SimpleFeature BOSSFIGHT_CHESTPRICE = register(new FeatureChestPrice()); public static final FeatureAutoReparty BOSSFIGHT_AUTOREPARTY = register(new FeatureAutoReparty()); public static final FeatureBoxRealLivid BOSSFIGHT_BOX_REALLIVID = register(new FeatureBoxRealLivid()); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureWarningOnPortal.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureWarningOnPortal.java new file mode 100644 index 00000000..686aa8d6 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureWarningOnPortal.java @@ -0,0 +1,174 @@ +package kr.syeyoung.dungeonsguide.features.impl.boss; + +import com.google.common.base.Supplier; +import kr.syeyoung.dungeonsguide.SkyblockStatus; +import kr.syeyoung.dungeonsguide.config.guiconfig.ConfigPanelCreator; +import kr.syeyoung.dungeonsguide.config.guiconfig.GuiConfig; +import kr.syeyoung.dungeonsguide.config.guiconfig.PanelDefaultParameterConfig; +import kr.syeyoung.dungeonsguide.config.types.AColor; +import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; +import kr.syeyoung.dungeonsguide.e; +import kr.syeyoung.dungeonsguide.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.features.impl.dungeon.FeatureDungeonScore; +import kr.syeyoung.dungeonsguide.features.text.*; +import kr.syeyoung.dungeonsguide.gui.MPanel; +import kr.syeyoung.dungeonsguide.utils.TextUtils; + +import java.util.*; + +public class FeatureWarningOnPortal extends SimpleFeature implements StyledTextProvider { + public FeatureWarningOnPortal() { + super("Bossfight", "Show warnings on red portal", "Display warnings such as\n- 'NOT ALL ROOMS DISCOVERED'\n- 'NOT ALL ROOMS COMPLETED'\n- 'Expected Score: 304'\n- 'MISSING 3 CRYPTS'\non portal", "bossfight.warningonportal"); + this.parameters.put("textStyles", new FeatureParameter<List<TextStyle>>("textStyles", "", "", new ArrayList<TextStyle>(), "list_textStyle")); + getStyles().add(new TextStyle("warning", new AColor(255, 0,0,255), new AColor(255, 255,255,255), false)); + getStyles().add(new TextStyle("field_name", new AColor(255, 72,255,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("field_separator", new AColor(204, 204,204,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("field_value", new AColor(255, 255,0,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("field_etc", new AColor(204, 204,204,255), new AColor(0, 0,0,0), false)); + } + + + private static final List<StyledText> dummyText = new ArrayList<StyledText>(); + static { + dummyText.add(new StyledText("!!!WARNING!!! <- text changes in boss-room\n", "warning")); + + dummyText.add(new StyledText("Total Secrets","field_name")); + dummyText.add(new StyledText(": ","field_separator")); + dummyText.add(new StyledText("103/100 ","field_value")); + dummyText.add(new StyledText("(103% 41.2 Explorer)","field_etc")); + + + dummyText.add(new StyledText("Crypts","field_name")); + dummyText.add(new StyledText(": ","field_separator")); + dummyText.add(new StyledText("5/5\n","field_value")); + + + dummyText.add(new StyledText("Deaths","field_name")); + dummyText.add(new StyledText(": ","field_separator")); + dummyText.add(new StyledText("0\n","field_value")); + + dummyText.add(new StyledText("Score Estimate","field_name")); + dummyText.add(new StyledText(": ","field_separator")); + dummyText.add(new StyledText("1000 ","field_value")); + dummyText.add(new StyledText("(S++++)\n","field_etc")); + + + dummyText.add(new StyledText("Skill","field_name")); + dummyText.add(new StyledText(": ","field_separator")); + dummyText.add(new StyledText("100 ","field_value")); + dummyText.add(new StyledText("(0 Deaths: 0 pts)\n","field_etc")); + + dummyText.add(new StyledText("Explorer","field_name")); + dummyText.add(new StyledText(": ","field_separator")); + dummyText.add(new StyledText("100 ","field_value")); + dummyText.add(new StyledText("(100% + secrets)\n","field_etc")); + + dummyText.add(new StyledText("Time","field_name")); + dummyText.add(new StyledText(": ","field_separator")); + dummyText.add(new StyledText("100 ","field_value")); + dummyText.add(new StyledText("(-30m 29s)\n","field_etc")); + + dummyText.add(new StyledText("Bonus","field_name")); + dummyText.add(new StyledText(": ","field_separator")); + dummyText.add(new StyledText("5\n","field_value")); + } + @Override + public List<StyledText> getDummyText() { + return dummyText; + } + + SkyblockStatus skyblockStatus = e.getDungeonsGuide().getSkyblockStatus(); + @Override + public List<StyledText> getText() { + ArrayList<StyledText> texts = new ArrayList<StyledText>(); + DungeonContext context = skyblockStatus.getContext(); + FeatureDungeonScore.ScoreCalculation scoreCalculation = FeatureRegistry.DUNGEON_SCORE.calculateScore(); + + if (context.getMapProcessor().getUndiscoveredRoom() > 0) { + texts.add(new StyledText("There are at least "+context.getMapProcessor().getUndiscoveredRoom()+" undiscovered rooms!\n", "warning")); + } else if (!scoreCalculation.isFullyCleared()) { + texts.add(new StyledText("Some rooms are not fully cleared!\n", "warning")); + } else if (scoreCalculation.getTombs() <= 5) { + texts.add(new StyledText("Only less than 5 crypts are blown up!\n", "warning")); + } else { + texts.add(new StyledText("\n", "warning")); + } + + texts.add(new StyledText("Total Secrets","field_name")); + texts.add(new StyledText(": ","field_separator")); + texts.add(new StyledText(scoreCalculation.getSecrets() +"/" + scoreCalculation.getTotalSecrets(),"field_value")); + texts.add(new StyledText(" ("+(int)(scoreCalculation.getSecrets() / (float)scoreCalculation.getTotalSecrets() * 100.0f)+"% "+(int)(scoreCalculation.getSecrets() / (float)scoreCalculation.getTotalSecrets() * 40.0f)+" Explorer)\n","field_etc")); + + + texts.add(new StyledText("Crypts","field_name")); + texts.add(new StyledText(": ","field_separator")); + texts.add(new StyledText(scoreCalculation.getTombs() +"/5\n","field_value")); + + + texts.add(new StyledText("Deaths","field_name")); + texts.add(new StyledText(": ","field_separator")); + texts.add(new StyledText(scoreCalculation.getDeaths() + "\n","field_value")); + + int sum = scoreCalculation.getTime() + scoreCalculation.getSecrets() + scoreCalculation.getExplorer() + scoreCalculation.getBonus(); + texts.add(new StyledText("Score Estimate","field_name")); + texts.add(new StyledText(": ","field_separator")); + texts.add(new StyledText(sum+" ","field_value")); + texts.add(new StyledText("("+FeatureRegistry.DUNGEON_SCORE.getLetter(sum)+")\n","field_etc")); + + + texts.add(new StyledText("Skill","field_name")); + texts.add(new StyledText(": ","field_separator")); + texts.add(new StyledText(scoreCalculation.getSkill()+" ","field_value")); + texts.add(new StyledText("("+scoreCalculation.getDeaths()+" Deaths: "+(scoreCalculation.getDeaths() * -2)+" pts)\n","field_etc")); + + texts.add(new StyledText("Explorer","field_name")); + texts.add(new StyledText(": ","field_separator")); + texts.add(new StyledText(scoreCalculation.getExplorer()+" ","field_value")); + texts.add(new StyledText("("+FeatureRegistry.DUNGEON_SCORE.getPercentage()+"% + secrets)\n","field_etc")); + + texts.add(new StyledText("Time","field_name")); + texts.add(new StyledText(": ","field_separator")); + texts.add(new StyledText(scoreCalculation.getTime()+" ","field_value")); + texts.add(new StyledText("("+ TextUtils.formatTime(FeatureRegistry.DUNGEON_SBTIME.getTimeElapsed())+")\n","field_etc")); + + texts.add(new StyledText("Bonus","field_name")); + texts.add(new StyledText(": ","field_separator")); + texts.add(new StyledText(scoreCalculation.getBonus()+"\n","field_value")); + + + return texts; + } + + public List<TextStyle> getStyles() { + return this.<List<TextStyle>>getParameter("textStyles").getValue(); + } + private Map<String, TextStyle> stylesMap; + public Map<String, TextStyle> getStylesMap() { + if (stylesMap == null) { + List<TextStyle> styles = getStyles(); + Map<String, TextStyle> res = new HashMap<String, TextStyle>(); + for (TextStyle ts : styles) { + res.put(ts.getGroupName(), ts); + } + stylesMap = res; + } + return stylesMap; + } + + + @Override + public String getEditRoute(final GuiConfig config) { + ConfigPanelCreator.map.put("base." + getKey() , new Supplier<MPanel>() { + @Override + public MPanel get() { + return new PanelDefaultParameterConfig(config, FeatureWarningOnPortal.this, + Arrays.asList(new MPanel[] { + new PanelTextParameterConfig(config, FeatureWarningOnPortal.this) + }), Collections.singleton("textStyles")); + } + }); + return "base." + getKey() ; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonScore.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonScore.java index 4c774d20..22a16eda 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonScore.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonScore.java @@ -222,7 +222,8 @@ public class FeatureDungeonScore extends TextHUDFeature { if (dungeonRoom.getTotalSecrets() != -1) totalSecrets += dungeonRoom.getTotalSecrets(); else totalSecretsKnown = false; - completed += dungeonRoom.getUnitPoints().size(); + if (dungeonRoom.getCurrentState() != DungeonRoom.RoomState.DISCOVERED) + completed += dungeonRoom.getUnitPoints().size(); } fullyCleared = completed >= getTotalRooms() && context.getMapProcessor().getUndiscoveredRoom() == 0; explorer += MathHelper.clamp_int((int) Math.floor(6.0 / 10.0 * getPercentage()), 0, 60); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/text/PanelTextParameterConfig.java b/src/main/java/kr/syeyoung/dungeonsguide/features/text/PanelTextParameterConfig.java index 3a87075c..adc4ca6d 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/text/PanelTextParameterConfig.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/text/PanelTextParameterConfig.java @@ -32,7 +32,7 @@ import java.util.List; public class PanelTextParameterConfig extends MPanel { - private TextHUDFeature feature; + private StyledTextProvider feature; private MEditableAColor currentColor; private MEditableAColor backgroundColor; @@ -48,7 +48,7 @@ public class PanelTextParameterConfig extends MPanel { } private GuiConfig config; - public PanelTextParameterConfig(final GuiConfig config, final TextHUDFeature feature) { + public PanelTextParameterConfig(final GuiConfig config, final StyledTextProvider feature) { this.config = config; this.feature = feature; setBackgroundColor(new Color(38, 38, 38, 255)); @@ -115,13 +115,13 @@ public class PanelTextParameterConfig extends MPanel { List<StyledText> texts = feature.getDummyText(); Map<String, TextStyle> styles = feature.getStylesMap(); - List<TextHUDFeature.StyleTextAssociated> calc = feature.drawTextWithStylesAssociated(texts, 0,0, styles); + List<StyledTextRenderer.StyleTextAssociated> calc = StyledTextRenderer.drawTextWithStylesAssociated(texts, 0,0, styles); boolean bool =clip.contains(absMousex, absMousey); - for (TextHUDFeature.StyleTextAssociated calc3: calc) { + for (StyledTextRenderer.StyleTextAssociated calc3: calc) { if (selected.contains(calc3.getStyledText().getGroup())) { Gui.drawRect(calc3.getRectangle().x, calc3.getRectangle().y, calc3.getRectangle().x + calc3.getRectangle().width, calc3.getRectangle().y + calc3.getRectangle().height, 0x4244A800); } else if (bool && calc3.getRectangle().contains((relMousex0-5 -offsetX) * scale , (relMousey0 - 5 - offsetY) * scale)) { - for (TextHUDFeature.StyleTextAssociated calc2 : calc) { + for (StyledTextRenderer.StyleTextAssociated calc2 : calc) { if (calc2.getStyledText().getGroup().equals(calc3.getStyledText().getGroup())) Gui.drawRect(calc2.getRectangle().x, calc2.getRectangle().y, calc2.getRectangle().x + calc2.getRectangle().width, calc2.getRectangle().y + calc2.getRectangle().height, 0x55777777); } @@ -163,8 +163,8 @@ public class PanelTextParameterConfig extends MPanel { Map<String, TextStyle> styles = feature.getStylesMap(); boolean existed = selected.isEmpty(); boolean found = false; - List<TextHUDFeature.StyleTextAssociated> calc = feature.calculate(texts, 0,0, styles); - for (TextHUDFeature.StyleTextAssociated calc3: calc) { + List<StyledTextRenderer.StyleTextAssociated> calc = StyledTextRenderer.calculate(texts, 0,0, styles); + for (StyledTextRenderer.StyleTextAssociated calc3: calc) { if (calc3.getRectangle().contains((relMouseX-5 -offsetX) * scale , (relMouseY - 5 - offsetY) * scale)) { if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) { if (!selected.contains(calc3.getStyledText().getGroup())) diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/text/StyledTextProvider.java b/src/main/java/kr/syeyoung/dungeonsguide/features/text/StyledTextProvider.java new file mode 100644 index 00000000..e354b744 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/text/StyledTextProvider.java @@ -0,0 +1,12 @@ +package kr.syeyoung.dungeonsguide.features.text; + +import java.util.List; +import java.util.Map; + +public interface StyledTextProvider { + List<StyledText> getDummyText(); + List<StyledText> getText(); + + List<TextStyle> getStyles(); + Map<String, TextStyle> getStylesMap(); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/text/StyledTextRenderer.java b/src/main/java/kr/syeyoung/dungeonsguide/features/text/StyledTextRenderer.java new file mode 100644 index 00000000..b20b2f33 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/text/StyledTextRenderer.java @@ -0,0 +1,106 @@ +package kr.syeyoung.dungeonsguide.features.text; + +import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import lombok.AllArgsConstructor; +import lombok.Data; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; + +import java.awt.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public class StyledTextRenderer { + public static List<StyleTextAssociated> drawTextWithStylesAssociated(List<StyledText> texts, int x, int y, Map<String, TextStyle> styleMap) { + int currX = x; + int currY = y; + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + int maxHeightForLine = 0; + List<StyleTextAssociated> associateds = new ArrayList<StyleTextAssociated>(); + for (StyledText st : texts) { + TextStyle ts = styleMap.get(st.getGroup()); + String[] lines = st.getText().split("\n"); + for (int i = 0; i < lines.length; i++) { + String str = lines[i]; + Dimension d = drawFragmentText(fr, str, ts, currX, currY, false); + associateds.add(new StyleTextAssociated(st, new Rectangle(currX, currY, d.width, d.height))); + currX += d.width; + if (maxHeightForLine < d.height) + maxHeightForLine = d.height; + + if (i+1 != lines.length) { + currY += maxHeightForLine ; + currX = x; + maxHeightForLine = 0; + } + } + if (st.getText().endsWith("\n")) { + currY += maxHeightForLine ; + currX = x; + maxHeightForLine = 0; + } + } + return associateds; + } + + public static List<StyleTextAssociated> calculate(List<StyledText> texts, int x, int y, Map<String, TextStyle> styleMap) { + int currX = x; + int currY = y; + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + int maxHeightForLine = 0; + List<StyleTextAssociated> associateds = new ArrayList<StyleTextAssociated>(); + for (StyledText st : texts) { + TextStyle ts = styleMap.get(st.getGroup()); + String[] lines = st.getText().split("\n"); + for (int i = 0; i < lines.length; i++) { + String str = lines[i]; + Dimension d = drawFragmentText(fr, str, ts, currX, currY, true); + associateds.add(new StyleTextAssociated(st, new Rectangle(currX, currY, d.width, d.height))); + currX += d.width; + if (maxHeightForLine < d.height) + maxHeightForLine = d.height; + + if (i+1 != lines.length) { + currY += maxHeightForLine; + currX = x; + maxHeightForLine = 0; + } + } + if (st.getText().endsWith("\n")) { + currY += maxHeightForLine; + currX = x; + maxHeightForLine = 0; + } + } + return associateds; + } + + @Data + @AllArgsConstructor + public static class StyleTextAssociated { + private StyledText styledText; + private Rectangle rectangle; + } + + public static Dimension drawFragmentText(FontRenderer fr, String content, TextStyle style, int x, int y, boolean stopDraw) { + if (stopDraw) + return new Dimension(fr.getStringWidth(content), fr.FONT_HEIGHT); + + Gui.drawRect(x,y, x+fr.getStringWidth(content), y + fr.FONT_HEIGHT, RenderUtils.getColorAt(x,y, style.getBackground())); + + if (!style.getColor().isChroma()) { + fr.drawString(content, x, y, style.getColor().getRGB(), style.isShadow()); + return new Dimension(fr.getStringWidth(content), fr.FONT_HEIGHT); + }else { + char[] charArr = content.toCharArray(); + int width = 0; + for (int i = 0; i < charArr.length; i++) { + fr.drawString(String.valueOf(charArr[i]), x + width, y, RenderUtils.getColorAt(x + width, y, style.getColor()), style.isShadow()); + width += fr.getCharWidth(charArr[i]); + } + return new Dimension(width, fr.FONT_HEIGHT); + } + } +} 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 c0e521f0..c80eb0db 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextHUDFeature.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextHUDFeature.java @@ -21,7 +21,7 @@ import java.awt.*; import java.util.*; import java.util.List; -public abstract class TextHUDFeature extends GuiFeature { +public abstract class TextHUDFeature extends GuiFeature implements StyledTextProvider { protected TextHUDFeature(String category, String name, String description, String key, boolean keepRatio, int width, int height) { super(category, name, description, key, keepRatio, width, height); this.parameters.put("textStyles", new FeatureParameter<List<TextStyle>>("textStyles", "", "", new ArrayList<TextStyle>(), "list_textStyle")); @@ -37,7 +37,7 @@ public abstract class TextHUDFeature extends GuiFeature { double scale = getFeatureRect().getHeight() / (fr.FONT_HEIGHT* countLines(asd)); GlStateManager.scale(scale, scale, 0); } - drawTextWithStylesAssociated(getText(), 0, 0, getStylesMap()); + StyledTextRenderer.drawTextWithStylesAssociated(getText(), 0, 0, getStylesMap()); } } @@ -53,7 +53,7 @@ public abstract class TextHUDFeature extends GuiFeature { double scale = getFeatureRect().getHeight() / (fr.FONT_HEIGHT * countLines(asd)); GlStateManager.scale(scale, scale, 0); } - drawTextWithStylesAssociated(getDummyText(), 0, 0, getStylesMap()); + StyledTextRenderer.drawTextWithStylesAssociated(getDummyText(), 0, 0, getStylesMap()); } public int countLines(List<StyledText> texts) { @@ -97,96 +97,6 @@ public abstract class TextHUDFeature extends GuiFeature { return stylesMap; } - public List<StyleTextAssociated> drawTextWithStylesAssociated(List<StyledText> texts, int x, int y, Map<String, TextStyle> styleMap) { - int currX = x; - int currY = y; - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - int maxHeightForLine = 0; - List<StyleTextAssociated> associateds = new ArrayList<StyleTextAssociated>(); - for (StyledText st : texts) { - TextStyle ts = styleMap.get(st.getGroup()); - String[] lines = st.getText().split("\n"); - for (int i = 0; i < lines.length; i++) { - String str = lines[i]; - Dimension d = drawFragmentText(fr, str, ts, currX, currY, false); - associateds.add(new StyleTextAssociated(st, new Rectangle(currX, currY, d.width, d.height))); - currX += d.width; - if (maxHeightForLine < d.height) - maxHeightForLine = d.height; - - if (i+1 != lines.length) { - currY += maxHeightForLine ; - currX = x; - maxHeightForLine = 0; - } - } - if (st.getText().endsWith("\n")) { - currY += maxHeightForLine ; - currX = x; - maxHeightForLine = 0; - } - } - return associateds; - } - - public List<StyleTextAssociated> calculate(List<StyledText> texts, int x, int y, Map<String, TextStyle> styleMap) { - int currX = x; - int currY = y; - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - int maxHeightForLine = 0; - List<StyleTextAssociated> associateds = new ArrayList<StyleTextAssociated>(); - for (StyledText st : texts) { - TextStyle ts = styleMap.get(st.getGroup()); - String[] lines = st.getText().split("\n"); - for (int i = 0; i < lines.length; i++) { - String str = lines[i]; - Dimension d = drawFragmentText(fr, str, ts, currX, currY, true); - associateds.add(new StyleTextAssociated(st, new Rectangle(currX, currY, d.width, d.height))); - currX += d.width; - if (maxHeightForLine < d.height) - maxHeightForLine = d.height; - - if (i+1 != lines.length) { - currY += maxHeightForLine; - currX = x; - maxHeightForLine = 0; - } - } - if (st.getText().endsWith("\n")) { - currY += maxHeightForLine; - currX = x; - maxHeightForLine = 0; - } - } - return associateds; - } - - @Data - @AllArgsConstructor - public static class StyleTextAssociated { - private StyledText styledText; - private Rectangle rectangle; - } - - public Dimension drawFragmentText(FontRenderer fr, String content, TextStyle style, int x, int y, boolean stopDraw) { - if (stopDraw) - return new Dimension(fr.getStringWidth(content), fr.FONT_HEIGHT); - - Gui.drawRect(x,y, x+fr.getStringWidth(content), y + fr.FONT_HEIGHT, RenderUtils.getColorAt(x,y, style.getBackground())); - - if (!style.getColor().isChroma()) { - fr.drawString(content, x, y, style.getColor().getRGB(), style.isShadow()); - return new Dimension(fr.getStringWidth(content), fr.FONT_HEIGHT); - }else { - char[] charArr = content.toCharArray(); - int width = 0; - for (int i = 0; i < charArr.length; i++) { - fr.drawString(String.valueOf(charArr[i]), x + width, y, RenderUtils.getColorAt(x + width, y, style.getColor()), style.isShadow()); - width += fr.getCharWidth(charArr[i]); - } - return new Dimension(width, fr.FONT_HEIGHT); - } - } @Override public String getEditRoute(final GuiConfig config) { diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/ProcessorFactory.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/ProcessorFactory.java index 6415eb6f..e0541bc8 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/ProcessorFactory.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/ProcessorFactory.java @@ -41,5 +41,7 @@ public class ProcessorFactory { registerRoomProcessor("puzzle_box", new RoomProcessorBoxSolver.Generator()); registerRoomProcessor("puzzle_trivia", new RoomProcessorTrivia.Generator());; registerRoomProcessor("puzzle_bombdefuse", new RoomProcessorBombDefuseSolver.Generator()); + + registerRoomProcessor("bossroom", new RoomProcessorRedRoom.Generator()); } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorRedRoom.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorRedRoom.java new file mode 100644 index 00000000..1f26392f --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorRedRoom.java @@ -0,0 +1,109 @@ +package kr.syeyoung.dungeonsguide.roomprocessor; + +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.doorfinder.DungeonDoor; +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.features.impl.boss.FeatureWarningOnPortal; +import kr.syeyoung.dungeonsguide.features.text.StyledTextRenderer; +import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.util.BlockPos; +import net.minecraft.util.MathHelper; +import net.minecraft.util.Vec3; +import org.lwjgl.opengl.GL11; + +import javax.vecmath.Vector3f; + +public class RoomProcessorRedRoom extends GeneralRoomProcessor { + public RoomProcessorRedRoom(DungeonRoom dungeonRoom) { + super(dungeonRoom); + BlockPos basePt = dungeonRoom.getMin().add(dungeonRoom.getMax()); + this.basePt = new Vec3(basePt.getX() / 2.0f, basePt.getY() / 2.0f, basePt.getZ() / 2.0f); + } + + Vec3 basePt; + int dir = 0; + + @Override + public void tick() { + BlockPos basePt = getDungeonRoom().getMin().add(getDungeonRoom().getMax()); + this.basePt = new Vec3(basePt.getX() / 2.0f, basePt.getY() / 2.0f + 4, basePt.getZ() / 2.0f); + DungeonDoor real = null; + for (DungeonDoor door : getDungeonRoom().getDoors()) { + if (door.isExist()) { + real = door;break; + } + } + if (real != null) { + OffsetPoint offsetPoint = new OffsetPoint(getDungeonRoom(), real.getPosition()); + offsetPoint = new OffsetPoint(33- offsetPoint.getX(), offsetPoint.getY(), 33 - offsetPoint.getZ()); + BlockPos opposite =offsetPoint.getBlockPos(getDungeonRoom()); + BlockPos dir = new BlockPos(real.getPosition().subtract(opposite)); + dir = new BlockPos(MathHelper.clamp_int(dir.getX() / 10, -1, 1), 0, MathHelper.clamp_int(dir.getZ() / 10, -1, 1)); + + this.basePt = new Vec3(opposite.add(dir.getX() * 6 + dir.getZ(), 3, dir.getZ() * 6 - dir.getX())); + + if (dir.getX() > 0) this.dir = 270; + else if (dir.getX() < 0) this.dir = 90; + else if (dir.getZ() < 0) this.dir = 0; + else if (dir.getZ() > 0) this.dir = 360; + else this.dir = Integer.MIN_VALUE; + } else { + dir = Integer.MIN_VALUE; + } + } + + @Override + public void drawWorld(float partialTicks) { + super.drawWorld(partialTicks); + if (!FeatureRegistry.BOSSFIGHT_WARNING_ON_PORTAL.isEnabled()) return; + + + FeatureWarningOnPortal featureWarningOnPortal = FeatureRegistry.BOSSFIGHT_WARNING_ON_PORTAL; + { + RenderManager renderManager = Minecraft.getMinecraft().getRenderManager(); + + Vector3f renderPos = RenderUtils.getRenderPos((float)basePt.xCoord,(float) basePt.yCoord, (float)basePt.zCoord, partialTicks); + + GlStateManager.color(1f, 1f, 1f, 0.5f); + GlStateManager.pushMatrix(); + GlStateManager.translate(renderPos.x, renderPos.y, renderPos.z); + if (dir == Integer.MIN_VALUE) + GlStateManager.rotate(-renderManager.playerViewY, 0.0f, 1.0f, 0.0f); + else + GlStateManager.rotate(dir, 0.0f, 1.0f, 0.0f); + GlStateManager.scale(-0.05f, -0.05f, 0.05f); + GlStateManager.disableLighting(); + GlStateManager.disableCull(); + GlStateManager.depthMask(false); GL11.glDisable(GL11.GL_DEPTH_TEST); + GlStateManager.disableDepth(); + GlStateManager.enableBlend(); + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + + + StyledTextRenderer.drawTextWithStylesAssociated(featureWarningOnPortal.getText(), 0, 0, featureWarningOnPortal.getStylesMap()); + + GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); + GlStateManager.depthMask(true); + GlStateManager.enableDepth(); + GlStateManager.enableCull(); + GlStateManager.popMatrix(); + } + } + + + public static class Generator implements RoomProcessorGenerator<RoomProcessorRedRoom> { + @Override + public RoomProcessorRedRoom createNew(DungeonRoom dungeonRoom) { + RoomProcessorRedRoom defaultRoomProcessor = new RoomProcessorRedRoom(dungeonRoom); + return defaultRoomProcessor; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java index 025d5890..a3464503 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java @@ -733,7 +733,7 @@ public class RenderUtils { GlStateManager.popMatrix(); } - private static Vector3f getRenderPos(float x, float y, float z, float partialTicks) { + public static Vector3f getRenderPos(float x, float y, float z, float partialTicks) { EntityPlayerSP sp = Minecraft.getMinecraft().thePlayer; return new Vector3f( x - (float) (sp.lastTickPosX + (sp.posX - sp.lastTickPosX) * partialTicks), |