Skip to content

Commit

Permalink
Add new checkmark style, add question marks
Browse files Browse the repository at this point in the history
  • Loading branch information
Harry282 committed Aug 13, 2024
1 parent be23a53 commit 7053554
Show file tree
Hide file tree
Showing 13 changed files with 56 additions and 50 deletions.
2 changes: 1 addition & 1 deletion src/main/kotlin/funnymap/config/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ object Config : Vigilant(File("./config/funnymap/config.toml"), "Funny Map", sor
description = "Adds room checkmarks based on room state.",
category = "Rooms",
subcategory = "Checkmarks",
options = ["None", "Default", "NEU"]
options = ["None", "Default", "NEU", "Legacy"]
)
var mapCheckmark = 1

Expand Down
54 changes: 6 additions & 48 deletions src/main/kotlin/funnymap/features/dungeon/MapRender.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,10 @@ import funnymap.utils.RenderUtils.grayScale
import funnymap.utils.Utils.equalsOneOf
import net.minecraft.client.gui.ScaledResolution
import net.minecraft.client.renderer.GlStateManager
import net.minecraft.util.ResourceLocation
import org.lwjgl.opengl.GL11
import java.awt.Color

object MapRender {

private val neuGreen = ResourceLocation("funnymap", "neu/green_check.png")
private val neuWhite = ResourceLocation("funnymap", "neu/white_check.png")
private val neuCross = ResourceLocation("funnymap", "neu/cross.png")
private val defaultGreen = ResourceLocation("funnymap", "default/green_check.png")
private val defaultWhite = ResourceLocation("funnymap", "default/white_check.png")
private val defaultCross = ResourceLocation("funnymap", "default/cross.png")

var dynamicRotation = 0f
var legitPeek = false

Expand Down Expand Up @@ -129,7 +120,7 @@ object MapRender {

var color = tile.color

if (tile.state.equalsOneOf(RoomState.UNDISCOVERED, RoomState.UNOPENED)) {
if (tile.state.equalsOneOf(RoomState.UNDISCOVERED, RoomState.UNOPENED) && !legitRender) {
if (Config.mapDarkenUndiscovered) {
color = color.darken(1 - Config.mapDarkenPercent)
}
Expand All @@ -147,6 +138,10 @@ object MapRender {
mapRoomSize,
color
)

if (legitRender && tile.state == RoomState.UNOPENED) {
RenderUtils.drawCheckmark(xOffset.toFloat(), yOffset.toFloat(), tile.state)
}
}

!xEven && !yEven -> {
Expand All @@ -173,10 +168,6 @@ object MapRender {
GlStateManager.translate(MapUtils.startCorner.first.toFloat(), MapUtils.startCorner.second.toFloat(), 0f)

val connectorSize = mapRoomSize shr 2
val checkmarkSize = when (Config.mapCheckmark) {
1 -> 8.0 // default
else -> 10.0 // neu
}

Dungeon.Info.uniqueRooms.forEach { unique ->
val room = unique.mainRoom
Expand All @@ -189,20 +180,7 @@ object MapRender {
val yOffsetName = (namePos.second / 2f) * (mapRoomSize + connectorSize)

if (Config.mapCheckmark != 0 && Config.mapRoomSecrets != 2) {
getCheckmark(room.state, Config.mapCheckmark)?.let {

GlStateManager.enableAlpha()
GlStateManager.color(255f, 255f, 255f, 255f)
mc.textureManager.bindTexture(it)

RenderUtils.drawTexturedQuad(
xOffsetCheck + (mapRoomSize - checkmarkSize) / 2,
yOffsetCheck + (mapRoomSize - checkmarkSize) / 2,
checkmarkSize,
checkmarkSize
)
GlStateManager.disableAlpha()
}
RenderUtils.drawCheckmark(xOffsetCheck, yOffsetCheck, room.state)
}

val color = if (Config.mapColorText) when (room.state) {
Expand Down Expand Up @@ -246,26 +224,6 @@ object MapRender {
GlStateManager.popMatrix()
}

private fun getCheckmark(state: RoomState, type: Int): ResourceLocation? {
return when (type) {
1 -> when (state) {
RoomState.CLEARED -> defaultWhite
RoomState.GREEN -> defaultGreen
RoomState.FAILED -> defaultCross
else -> null
}

2 -> when (state) {
RoomState.CLEARED -> neuWhite
RoomState.GREEN -> neuGreen
RoomState.FAILED -> neuCross
else -> null
}

else -> null
}
}

private fun renderPlayerHeads() {
try {
if (Dungeon.dungeonTeammates.isEmpty()) {
Expand Down
22 changes: 22 additions & 0 deletions src/main/kotlin/funnymap/utils/CheckmarkSet.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package funnymap.utils

import funnymap.core.map.RoomState
import funnymap.features.dungeon.MapRender
import net.minecraft.util.ResourceLocation

class CheckmarkSet(val size: Int, location: String) {
private val crossResource = ResourceLocation("funnymap", "$location/cross.png")
private val greenResource = ResourceLocation("funnymap", "$location/green_check.png")
private val questionResource = ResourceLocation("funnymap", "$location/question.png")
private val whiteResource = ResourceLocation("funnymap", "$location/white_check.png")

fun getCheckmark(state: RoomState): ResourceLocation? {
return when (state) {
RoomState.CLEARED -> whiteResource
RoomState.GREEN -> greenResource
RoomState.FAILED -> crossResource
RoomState.UNOPENED -> if (MapRender.legitRender) questionResource else null
else -> null
}
}
}
28 changes: 27 additions & 1 deletion src/main/kotlin/funnymap/utils/RenderUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package funnymap.utils
import funnymap.FunnyMap.mc
import funnymap.config.Config
import funnymap.core.DungeonPlayer
import funnymap.core.map.RoomState
import funnymap.features.dungeon.DungeonScan
import funnymap.features.dungeon.MapRender
import funnymap.utils.Utils.equalsOneOf
Expand All @@ -26,6 +27,9 @@ object RenderUtils {

private val tessellator: Tessellator = Tessellator.getInstance()
private val worldRenderer: WorldRenderer = tessellator.worldRenderer
private val neuCheckmarks = CheckmarkSet(10, "neu")
private val defaultCheckmarks = CheckmarkSet(16, "default")
private val legacyCheckmarks = CheckmarkSet(8, "legacy")
private val mapIcons = ResourceLocation("funnymap", "marker.png")

private fun preDraw() {
Expand All @@ -50,7 +54,7 @@ object RenderUtils {
worldRenderer.pos(x, y, 0.0).endVertex()
}

fun drawTexturedQuad(x: Double, y: Double, width: Double, height: Double) {
private fun drawTexturedQuad(x: Double, y: Double, width: Double, height: Double) {
worldRenderer.begin(GL_QUADS, DefaultVertexFormats.POSITION_TEX)
worldRenderer.pos(x, y + height, 0.0).tex(0.0, 1.0).endVertex()
worldRenderer.pos(x + width, y + height, 0.0).tex(1.0, 1.0).endVertex()
Expand Down Expand Up @@ -133,6 +137,28 @@ object RenderUtils {
GlStateManager.popMatrix()
}

fun drawCheckmark(x: Float, y: Float, state: RoomState) {
val (checkmark, size) = when (Config.mapCheckmark) {
1 -> defaultCheckmarks.getCheckmark(state) to defaultCheckmarks.size.toDouble()
2 -> neuCheckmarks.getCheckmark(state) to neuCheckmarks.size.toDouble()
3 -> legacyCheckmarks.getCheckmark(state) to legacyCheckmarks.size.toDouble()
else -> return
}
if (checkmark != null) {
GlStateManager.enableAlpha()
GlStateManager.color(1f, 1f, 1f, 1f)
mc.textureManager.bindTexture(checkmark)

drawTexturedQuad(
x + (MapUtils.mapRoomSize - size) / 2,
y + (MapUtils.mapRoomSize - size) / 2,
size,
size
)
GlStateManager.disableAlpha()
}
}

fun drawPlayerHead(name: String, player: DungeonPlayer) {
GlStateManager.pushMatrix()
try {
Expand Down
Binary file modified src/main/resources/assets/funnymap/default/cross.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/resources/assets/funnymap/default/green_check.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/resources/assets/funnymap/default/white_check.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/assets/funnymap/legacy/cross.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/assets/funnymap/neu/question.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7053554

Please sign in to comment.