diff --git a/src/main/kotlin/dartzee/bean/GameSetupPlayerSelector.kt b/src/main/kotlin/dartzee/bean/GameSetupPlayerSelector.kt index 9c3abd30..d63c6820 100644 --- a/src/main/kotlin/dartzee/bean/GameSetupPlayerSelector.kt +++ b/src/main/kotlin/dartzee/bean/GameSetupPlayerSelector.kt @@ -4,6 +4,9 @@ import dartzee.core.bean.ScrollTableOrdered import dartzee.core.util.DialogUtil import dartzee.core.util.setMargins import dartzee.db.MAX_PLAYERS +import dartzee.utils.InjectedThings +import dartzee.utils.ResourceCache +import java.awt.Font import java.awt.event.ActionEvent import javax.swing.ImageIcon import javax.swing.JToggleButton @@ -15,6 +18,13 @@ class GameSetupPlayerSelector : AbstractPlayerSelector() { init { super.render() + if (InjectedThings.partyMode) { + val font = ResourceCache.BASE_FONT.deriveFont(Font.PLAIN, 24f) + tablePlayersToSelectFrom.setTableFont(font) + tablePlayersSelected.setTableFont(font) + } + + btnPairs.icon = ImageIcon(javaClass.getResource("/buttons/teams.png")) btnPairs.toolTipText = "Play in pairs" tablePlayersSelected.addButtonToOrderingPanel(btnPairs, 3) diff --git a/src/main/kotlin/dartzee/bean/ScrollTablePlayers.kt b/src/main/kotlin/dartzee/bean/ScrollTablePlayers.kt index dbf90840..d9f38dad 100644 --- a/src/main/kotlin/dartzee/bean/ScrollTablePlayers.kt +++ b/src/main/kotlin/dartzee/bean/ScrollTablePlayers.kt @@ -3,6 +3,10 @@ package dartzee.bean import dartzee.core.bean.ScrollTable import dartzee.core.util.TableUtil import dartzee.db.PlayerEntity +import dartzee.utils.InjectedThings +import dartzee.utils.getAvatarImage +import dartzee.utils.resize +import javax.swing.ImageIcon fun ScrollTable.getSelectedPlayer(): PlayerEntity? { val row = table.selectedRow @@ -22,8 +26,14 @@ fun ScrollTable.initPlayerTableModel(players: List = listOf()) { this.model = model - setRowHeight(23) - setColumnWidths("25") + if (InjectedThings.partyMode) { + setRowHeight(50) + setColumnWidths("50") + } else { + setRowHeight(23) + setColumnWidths("25") + } + addPlayers(players) @@ -34,7 +44,7 @@ fun ScrollTable.initPlayerTableModel(players: List = listOf()) { fun ScrollTable.addPlayers(players: List) = players.forEach(::addPlayer) private fun ScrollTable.addPlayer(player: PlayerEntity) { - val flag = player.getFlag() + val flag = if (InjectedThings.partyMode) ImageIcon(player.getAvatarImage().resize(50, 50)) else player.getFlag() val row = arrayOf(flag, player) addRow(row) diff --git a/src/main/kotlin/dartzee/utils/PlayerImageUtils.kt b/src/main/kotlin/dartzee/utils/PlayerImageUtils.kt index 33145438..9f21671d 100644 --- a/src/main/kotlin/dartzee/utils/PlayerImageUtils.kt +++ b/src/main/kotlin/dartzee/utils/PlayerImageUtils.kt @@ -54,7 +54,7 @@ fun splitAvatar( return ImageIcon(newImage) } -private fun PlayerEntity.getAvatarImage() = getAvatar().toBufferedImage(BufferedImage.TYPE_INT_RGB) +fun PlayerEntity.getAvatarImage() = getAvatar().toBufferedImage(BufferedImage.TYPE_INT_RGB) fun combinePlayerFlags(flagOne: ImageIcon, flagTwo: ImageIcon): ImageIcon { val imageOne = flagOne.toBufferedImage(BufferedImage.TYPE_INT_ARGB) @@ -121,11 +121,12 @@ fun convertImageToAvatarDimensions(imageBytes: ByteArray): ByteArray { val croppedImage = image.getSubimage(xc, yc, minDimension, minDimension) val resizedImage = - croppedImage - .getScaledInstance(PLAYER_IMAGE_WIDTH, PLAYER_IMAGE_HEIGHT, BufferedImage.SCALE_SMOOTH) - .toBufferedImage(PLAYER_IMAGE_WIDTH, PLAYER_IMAGE_HEIGHT) + croppedImage.resize(PLAYER_IMAGE_WIDTH, PLAYER_IMAGE_HEIGHT) val baos = ByteArrayOutputStream() ImageIO.write(resizedImage, "jpg", baos) return baos.toByteArray() } + +fun BufferedImage.resize(width: Int, height: Int = width) = + getScaledInstance(width, height, BufferedImage.SCALE_SMOOTH).toBufferedImage(width, height)