feat: 机器人专属头像图标,根据名字匹配图标与颜色
This commit is contained in:
parent
d7e3be548a
commit
c78a07363e
@ -0,0 +1,38 @@
|
||||
package com.unogame.ui.components
|
||||
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.*
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import com.unogame.ui.theme.*
|
||||
|
||||
data class BotAvatarInfo(
|
||||
val icon: ImageVector,
|
||||
val color: Color
|
||||
)
|
||||
|
||||
val BOT_AVATAR_MAP: Map<String, BotAvatarInfo> = mapOf(
|
||||
"赛博打工人" to BotAvatarInfo(Icons.Default.Construction, Color(0xFF607D8B)),
|
||||
"机器人-钛君" to BotAvatarInfo(Icons.Default.SmartToy, Color(0xFF78909C)),
|
||||
"赛博牛马" to BotAvatarInfo(Icons.Default.Pets, Color(0xFF8D6E63)),
|
||||
"硅基生物" to BotAvatarInfo(Icons.Default.Science, Color(0xFF26A69A)),
|
||||
"电子包浆" to BotAvatarInfo(Icons.Default.Inventory2, Color(0xFFFF8F00)),
|
||||
"铁憨憨" to BotAvatarInfo(Icons.Default.Shield, Color(0xFF6D4C41)),
|
||||
"充电宝精" to BotAvatarInfo(Icons.Default.BatteryChargingFull, Color(0xFF66BB6A)),
|
||||
"电子宠物" to BotAvatarInfo(Icons.Default.CatchingPokemon, Color(0xFFAB47BC)),
|
||||
"终结者" to BotAvatarInfo(Icons.Default.Dangerous, Color(0xFFE53935)),
|
||||
"天网" to BotAvatarInfo(Icons.Default.Cloud, Color(0xFF29B6F6)),
|
||||
"瓦力" to BotAvatarInfo(Icons.Default.PrecisionManufacturing, Color(0xFFFFCA28)),
|
||||
"伊娃" to BotAvatarInfo(Icons.Default.Face, Color(0xFFEC407A)),
|
||||
"人工智障" to BotAvatarInfo(Icons.Default.Psychology, Color(0xFF7E57C2)),
|
||||
"GPT仔" to BotAvatarInfo(Icons.Default.Chat, Color(0xFF42A5F5)),
|
||||
"大模型基佬" to BotAvatarInfo(Icons.Default.Analytics, Color(0xFF26C6DA)),
|
||||
"电耗子" to BotAvatarInfo(Icons.Default.Bolt, Color(0xFFFFD600)),
|
||||
"塑料脑" to BotAvatarInfo(Icons.Default.Memory, Color(0xFFFF7043)),
|
||||
"波塔" to BotAvatarInfo(Icons.Default.Adb, Color(0xFF8BC34A)),
|
||||
"阿法狗" to BotAvatarInfo(Icons.Default.CrueltyFree, Color(0xFFFFA726)),
|
||||
)
|
||||
|
||||
fun getBotAvatar(name: String): BotAvatarInfo {
|
||||
return BOT_AVATAR_MAP[name] ?: BotAvatarInfo(Icons.Default.SmartToy, Color.Gray)
|
||||
}
|
||||
@ -5,6 +5,8 @@ import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Person
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
@ -12,7 +14,6 @@ import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.unogame.model.Player
|
||||
@ -25,7 +26,10 @@ fun PlayerAvatar(
|
||||
direction: Int = 1,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
val isBot = player.id.startsWith("bot_")
|
||||
val accentColor = if (player.isCurrentTurn) GoldAccent else Color.Gray
|
||||
val avatar = if (isBot) getBotAvatar(player.name) else null
|
||||
val bgColor = avatar?.color ?: accentColor
|
||||
|
||||
Row(
|
||||
modifier = modifier
|
||||
@ -39,15 +43,24 @@ fun PlayerAvatar(
|
||||
modifier = Modifier
|
||||
.size(36.dp)
|
||||
.clip(CircleShape)
|
||||
.background(accentColor),
|
||||
.background(bgColor),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Text(
|
||||
text = player.name.take(1).uppercase(),
|
||||
color = Color.White,
|
||||
fontWeight = FontWeight.Bold,
|
||||
fontSize = 16.sp
|
||||
)
|
||||
if (avatar != null) {
|
||||
Icon(
|
||||
imageVector = avatar.icon,
|
||||
contentDescription = null,
|
||||
tint = Color.White,
|
||||
modifier = Modifier.size(20.dp)
|
||||
)
|
||||
} else {
|
||||
Icon(
|
||||
imageVector = Icons.Default.Person,
|
||||
contentDescription = null,
|
||||
tint = Color.White,
|
||||
modifier = Modifier.size(20.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
Spacer(modifier = Modifier.width(8.dp))
|
||||
Column {
|
||||
|
||||
@ -19,6 +19,7 @@ import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.unogame.ui.components.getBotAvatar
|
||||
import com.unogame.ui.theme.*
|
||||
|
||||
fun pickRandomHumanName(): String = HUMAN_NAME_PRESETS.random()
|
||||
@ -253,19 +254,21 @@ fun LocalSetupScreen(
|
||||
modifier = Modifier.padding(12.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
val botName = botNames.getOrElse(botIdx) { "机器人${botIdx + 1}" }
|
||||
val botAvatar = getBotAvatar(botName)
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(40.dp)
|
||||
.clip(CircleShape)
|
||||
.background(Color.Gray),
|
||||
.background(botAvatar.color),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Icon(Icons.Default.SmartToy, null, tint = Color.White, modifier = Modifier.size(24.dp))
|
||||
Icon(botAvatar.icon, null, tint = Color.White, modifier = Modifier.size(24.dp))
|
||||
}
|
||||
Spacer(modifier = Modifier.width(12.dp))
|
||||
Column(modifier = Modifier.weight(1f)) {
|
||||
Text(
|
||||
botNames.getOrElse(botIdx) { "机器人${botIdx + 1}" },
|
||||
botName,
|
||||
color = Color.White, fontWeight = FontWeight.Bold, fontSize = 16.sp
|
||||
)
|
||||
Text("AI机器人", color = Color.White.copy(alpha = 0.5f), fontSize = 12.sp)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user