feat: imported input-box pets, with dsh-Go's sprite packs
Nothing is built in: Settings → 宠物 shows "尚未导入宠物" until a zip is picked. The zip holds a dsh-Go pack.json and PNG sheets; it is validated (pack.json, every named sheet) and unpacked under the app's private files directory, with enable, size (40/52/64) and remove kept on the device. A pack's canvas, anchor, per-animation box and frame list drive rendering: PetSlot reserves the area above the baseline and stands the sprite on the composer's top edge (or on the activity cap while a turn runs). Idle, thinking, working and error follow the chat's state, and a tap plays the pack's react-left/react-right. Only one sheet is decoded at a time. path_provider's JNI binding does not load on this engine, so MainActivity exposes the files directory over a tiny method channel instead. dist/deepy-whale-pet.zip is the Deepy whale for testing. Tests cover the real pack manifest, frame/state mapping and zip import. 0.4.0 (400).
This commit is contained in:
1 parent
ff0dbf1b37
commit
d72af036a1
16 files changed
+1410
-12
No files matched your search
@@ -12,6 +12,7 @@ import '../state.dart';
|
||||
import '../widgets/composer_attachment.dart';
|
||||
import '../widgets/markdown_view.dart';
|
||||
import '../widgets/composer_box.dart';
|
||||
import '../widgets/pet_sprite.dart';
|
||||
import '../widgets/model_controls.dart';
|
||||
import '../widgets/slash_palette.dart';
|
||||
import '../widgets/usage_ring.dart';
|
||||
@@ -169,6 +170,7 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
Expanded(child: _messageList()),
|
||||
_permissions(),
|
||||
_forms(),
|
||||
PetSlot(state: _petState()),
|
||||
if (chat.running) _activityStrip(),
|
||||
_composer(widget.keyboardInset),
|
||||
],
|
||||
@@ -1341,6 +1343,21 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
/// The mood the pet draws: the same activity the strip shows, then a failed
|
||||
/// last turn, then idle.
|
||||
String _petState() {
|
||||
if (chat.running) {
|
||||
return _activity().title == '思考中' ? 'thinking' : 'working';
|
||||
}
|
||||
for (var i = chat.msgs.length - 1; i >= 0; i--) {
|
||||
final m = chat.msgs[i];
|
||||
if (m.type == 'assistant' || m.type == 'idle') {
|
||||
return m.error != null && !m.error!.isEmpty ? 'error' : 'idle';
|
||||
}
|
||||
}
|
||||
return 'idle';
|
||||
}
|
||||
|
||||
/// What the agent is doing right now, for the strip above the composer.
|
||||
({String title, String detail}) _activity() {
|
||||
for (var i = chat.msgs.length - 1; i >= 0; i--) {
|
||||
|
||||
Reference in new issue
Block a user