All Downloads are FREE. Search and download functionalities are using the official Maven repository.

dev.robocode.tankroyale.gui.ui.newbattle.BotInfoListCellRenderer.kt Maven / Gradle / Ivy

package dev.robocode.tankroyale.gui.ui.newbattle

import dev.robocode.tankroyale.gui.model.BotInfo
import javax.swing.JList

class BotInfoListCellRenderer : AbstractListCellRenderer() {

    override fun onRender(list: JList?, value: Any?, index: Int, isSelected: Boolean, cellHasFocus: Boolean) {
        (value as BotInfo).apply {
            text = "$displayText (${host(host)}:$port)" + (teamName?.let { " / $teamName $teamVersion" } ?: "")
        }
    }

    private fun host(hostName: String) =
        if (hostName == "0:0:0:0:0:0:0:1" || hostName == "127.0.0.1") {
            "localhost"
        } else {
            hostName
        }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy