feat(v1.2): 阶段1 —— 立绘表五档 + 回退链 + 编辑界面(v2.0.56)
按 v1.2 需求,`front` 从单文件名扩成五档立绘表,立绘随情绪自动切换。 ## 数据层 `store.normalize_image`:兼容规则是需求原话的"旧格式视为仅有「平常」档"。 ★ 放在**读**的时候归一化(`list_agents` 出口),不是写的时候: 老数据已经在 agents.json 里了,写时归一化管不到它们;读时归一化一次 覆盖新旧两种,而且写入路径一行都不用改。 ★ 归一化不丢信息:字典里多出来的自定义档位原样保留。 ## 回退链 `agent_api.portrait_of`:`当前 preset 档 → 平常档 → 旧单一 front → 空串` (空串 = 界面用内置默认人物)。 ★ 由内核算好、经 `/api/state` 的 `portrait` 字段给界面 —— 回退链是**一条规则**, 而选择界面、对话界面、编辑预览三处都要用。 ★ 查 `os.path.isfile`:用户可能手动删过 agent-assets 里的文件, 指着不存在的路径会让界面显示空白,比回退到默认图糟得多。 ## 落盘与槽位 - `_save_assets`:front 单独处理,每档文件名带档位(`front-喜-happy.png`), 否则五档会互相覆盖;老格式落成「平常」档 - `_set_asset`:槽位名支持 `front:喜`(不带档位视为「平常」,兼容旧调用); 换图时把旧文件删掉,不然越攒越多 ## 界面 - `AgentImage.front` 从 String 改成 `Map<String, String>` + 新增 `portrait` - 所有显示处改用 `portrait`(编译器一次列出 5 个文件 11 处,逐个改的) - 编辑界面外观组拆两段:**角色立绘(五档,每档带"缺了退回哪张"的说明)** + 其他三件套 ## 验证 探针第 19 节 10 项,**真造文件**测(回退链里有一环是 os.path.isfile, 不落真文件测不到):老格式归一化、命中当前档、回退平常、 连平常都没有时用任意可用档、**档位文件被删时跳过它**、完全没图返回空串、 归一化保留自定义档位、自定义档位也能被选中。 装机实测五档编辑器。全部探针 + audit-ui-tree 全绿。 ## 阶段 1 剩余(很小的尾巴) 立绘切换的 crossfade(0.3s)放到阶段 5 的 §4.4 一起做 —— 那时要同时处理"群聊背景跟随发言者",两处共用同一套缓动参数。
This commit is contained in:
@@ -30,8 +30,8 @@ android {
|
||||
* versionCode 每次发版 +1(Android 靠它判断"能不能覆盖安装",
|
||||
* 改小了会装不上)。
|
||||
*/
|
||||
versionCode = 255
|
||||
versionName = "2.0.55"
|
||||
versionCode = 256
|
||||
versionName = "2.0.56"
|
||||
|
||||
ndk {
|
||||
// Chaquopy 只支持这两个;Termux bootstrap 也只准备了这两份
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.doubao.lynxclone.ui
|
||||
package com.doubao.lynxclone.ui
|
||||
|
||||
import android.util.Base64
|
||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||
@@ -43,6 +43,7 @@ import androidx.compose.ui.unit.sp
|
||||
import com.doubao.lynxclone.R
|
||||
import com.doubao.lynxclone.data.Agent
|
||||
import com.doubao.lynxclone.data.AgentImage
|
||||
import com.doubao.lynxclone.data.PRESETS
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.foundation.Image
|
||||
|
||||
@@ -65,14 +66,22 @@ import androidx.compose.foundation.Image
|
||||
* ③ **限额 0 就是无限制**,不是"限额为 0"。
|
||||
*/
|
||||
|
||||
/** 外观四件套在界面上的顺序和文案 */
|
||||
/** 除立绘以外的三件套(立绘是**五档**的,单独处理) */
|
||||
private val ASSET_SLOTS = listOf(
|
||||
Triple("front", "角色图", "展示区中间的主体形象;缺了用内置默认人物"),
|
||||
Triple("back", "背景图", "铺在展示区最底层;缺了用内置默认背景"),
|
||||
Triple("border-main", "主体边框", "框住整个展示区;缺了用简单方框"),
|
||||
Triple("border-info", "介绍边框", "围住介绍文本;缺了跟主体边框一个样式"),
|
||||
)
|
||||
|
||||
/** 立绘五档各档的说明 —— 每档都要写清"缺了会退回哪张",不然用户不知道该传几张 */
|
||||
private fun portraitHint(preset: String): String = when (preset) {
|
||||
"喜" -> "高兴时用这张;缺了用「平常」那张"
|
||||
"怒" -> "发怒时用这张;缺了用「平常」那张"
|
||||
"哀" -> "悲伤时用这张;缺了用「平常」那张"
|
||||
"死亡" -> "死亡时用这张(那时不能对话);缺了用「平常」那张"
|
||||
else -> "其他档都缺时兜底用这张;连它也没有就用内置默认人物"
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun AgentEditScreen(
|
||||
vm: AppViewModel,
|
||||
@@ -173,6 +182,35 @@ fun AgentEditScreen(
|
||||
color = doubaoTextSecondary(),
|
||||
)
|
||||
} else {
|
||||
// ---- 立绘:五档(v1.2 需求 2.5 / 2.6)----
|
||||
//
|
||||
// ★ 槽位名带档位(`front:喜`),内核按这个落到不同文件 ——
|
||||
// 五档存成一张的话会互相覆盖。
|
||||
Text("角色立绘(按情绪换)", fontSize = 13.sp, color = doubaoText())
|
||||
Spacer(Modifier.height(2.dp))
|
||||
Hint(
|
||||
"情绪的五档各自一张图,缺哪档就退回「平常」那张。" +
|
||||
"现在显示的是「${draft.image.portrait.ifBlank { "内置默认人物" }}」那张。",
|
||||
)
|
||||
Spacer(Modifier.height(8.dp))
|
||||
for (preset in PRESETS) {
|
||||
AssetRow(
|
||||
title = preset,
|
||||
desc = portraitHint(preset),
|
||||
path = draft.image.slot(preset),
|
||||
onPick = {
|
||||
pendingSlot = "front:$preset"
|
||||
pickImage.launch(arrayOf("image/*"))
|
||||
},
|
||||
onClear = { vm.uploadAgentAsset(draft.id, "front:$preset", "", "") },
|
||||
)
|
||||
Spacer(Modifier.height(6.dp))
|
||||
}
|
||||
Spacer(Modifier.height(6.dp))
|
||||
|
||||
// ---- 其余三件套 ----
|
||||
Text("其他三件套", fontSize = 13.sp, color = doubaoText())
|
||||
Spacer(Modifier.height(6.dp))
|
||||
for ((key, title, desc) in ASSET_SLOTS) {
|
||||
AssetRow(
|
||||
title = title,
|
||||
@@ -387,7 +425,9 @@ fun AgentEditScreen(
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
private fun AgentImage.pathOf(key: String): String = when (key) {
|
||||
"front" -> front
|
||||
// v1.2:立绘是五档表,编辑界面的**预览**用内核算好的那张
|
||||
// (其他三件套还是单张)
|
||||
"front" -> portrait
|
||||
"back" -> back
|
||||
"border-main" -> borderMain
|
||||
else -> borderInfo
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.doubao.lynxclone.ui
|
||||
package com.doubao.lynxclone.ui
|
||||
|
||||
import androidx.compose.animation.core.Animatable
|
||||
import androidx.compose.animation.core.FastOutSlowInEasing
|
||||
@@ -256,7 +256,7 @@ fun AgentSelectScreen(
|
||||
Modifier.fillMaxSize().offset(x = (frontShift.value * 200).dp),
|
||||
) {
|
||||
ArtworkFill(
|
||||
shownAgent.image.front,
|
||||
shownAgent.image.portrait,
|
||||
R.drawable.agent_default_character,
|
||||
alpha = frontAlpha.value,
|
||||
scale = ContentScale.Fit,
|
||||
@@ -467,7 +467,7 @@ private fun AgentList(
|
||||
// ★ alignment = TopCenter:角色图是竖长的,居中裁剪只会
|
||||
// 裁出"腰到大腿",一排缩略图全是裤子
|
||||
AssetImage(
|
||||
path = agent.image.front,
|
||||
path = agent.image.portrait,
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
contentScale = ContentScale.Crop,
|
||||
alignment = Alignment.TopCenter,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.doubao.lynxclone.ui
|
||||
package com.doubao.lynxclone.ui
|
||||
|
||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
@@ -459,7 +459,7 @@ private fun ChatHeader(vm: AppViewModel, agentName: String, speech: SpeechContro
|
||||
) {
|
||||
// 有自定义角色图就显示它(需求 2.5 的资源回退在内核侧已经落定,
|
||||
// 这里 path 为空就还是原来的图标)
|
||||
val art = vm.activeAgent?.image?.front ?: ""
|
||||
val art = vm.activeAgent?.image?.portrait.orEmpty()
|
||||
if (art.isNotBlank()) {
|
||||
AssetImage(
|
||||
path = art,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.doubao.lynxclone.ui
|
||||
package com.doubao.lynxclone.ui
|
||||
|
||||
import android.util.Base64
|
||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||
@@ -265,7 +265,7 @@ fun ResourcesScreen(vm: AppViewModel, onBack: () -> Unit) {
|
||||
.border(0.5.dp, Doubao.Border, RoundedCornerShape(8.dp)),
|
||||
) {
|
||||
AssetImage(
|
||||
path = image.front,
|
||||
path = image.slot("平常"),
|
||||
modifier = Modifier.fillMaxSize().clip(RoundedCornerShape(8.dp)),
|
||||
contentScale = ContentScale.Crop,
|
||||
)
|
||||
@@ -501,7 +501,7 @@ private fun ResourceEditScreen(
|
||||
)
|
||||
for ((key, title, desc) in slots) {
|
||||
val path = when (key) {
|
||||
"front" -> worldImage.front
|
||||
"front" -> worldImage.slot("平常")
|
||||
"back" -> worldImage.back
|
||||
"border-main" -> worldImage.borderMain
|
||||
else -> worldImage.borderInfo
|
||||
|
||||
Reference in New Issue
Block a user