Skip to content

Commit

Permalink
Improve image import error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Wyvest committed Jun 20, 2024
1 parent b320c4b commit ace500d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/main/kotlin/org/polyfrost/crosshair/config/Drawer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,11 @@ object Drawer : BasicOption(null, null, "", "", "", "", 2) {

fun loadImage(image: BufferedImage?, save: Boolean, entry: CrosshairEntry = CrosshairEntry()): OneImage? {
val loadedImage = OneImage(image)
if (loadedImage.width != loadedImage.height || loadedImage.width !in 15..32) {
notify("Image size isn't supported.")
val dimensionsSame = loadedImage.width == loadedImage.height
val withinSize = loadedImage.width in 15..32
if (!dimensionsSame || !withinSize) {
val message = if (!dimensionsSame) "The width of the image must be equal to the height" else "The image must be between 15x15 and 32x32 pixels"
notify("$message (width: ${loadedImage.width} height: ${loadedImage.height}).")
return null
}
ModConfig.newCurrentCrosshair.loadFrom(entry)
Expand Down

0 comments on commit ace500d

Please sign in to comment.