cc-pets 2.1.1 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CC_BRIDGE.md +5 -0
- package/CC_BRIDGE.zh-CN.md +4 -0
- package/CHANGELOG.md +40 -1
- package/CHANGELOG.zh-CN.md +40 -1
- package/CONTRIBUTING.md +54 -0
- package/CONTRIBUTING.zh-CN.md +45 -0
- package/README.md +57 -14
- package/README.zh-CN.md +56 -14
- package/Resources/Info.plist +3 -1
- package/Resources/en.lproj/InfoPlist.strings +1 -0
- package/Resources/phrases.default.en.txt +182 -0
- package/Resources/zh-Hans.lproj/InfoPlist.strings +1 -0
- package/Resources/zh-Hans.lproj/Localizable.strings +332 -0
- package/Sources/CCPets/CCPetsAppDelegate+AgentEvents.m +215 -0
- package/Sources/CCPets/CCPetsAppDelegate+AgentStatus.m +660 -0
- package/Sources/CCPets/CCPetsAppDelegate+Bridge.m +299 -0
- package/Sources/CCPets/CCPetsAppDelegate+Pets.m +185 -0
- package/Sources/CCPets/CCPetsAppDelegate+Private.h +325 -0
- package/Sources/CCPets/CCPetsAppDelegate+Quota.m +216 -0
- package/Sources/CCPets/CCPetsAppDelegate+Settings.m +226 -0
- package/Sources/CCPets/CCPetsAppDelegate+Speech.m +392 -0
- package/Sources/CCPets/CCPetsAppDelegate+Update.m +459 -0
- package/Sources/CCPets/CCPetsAppDelegate.h +13 -14
- package/Sources/CCPets/CCPetsAppDelegate.m +68 -2466
- package/Sources/CCPets/CCPetsCleanup.h +4 -0
- package/Sources/CCPets/CCPetsCleanup.m +41 -7
- package/Sources/CCPets/CCPetsEvents.m +4 -3
- package/Sources/CCPets/CCPetsL10n.h +55 -0
- package/Sources/CCPets/CCPetsL10n.m +219 -0
- package/Sources/CCPets/CCPetsPaths.h +0 -1
- package/Sources/CCPets/CCPetsPaths.m +0 -1
- package/Sources/CCPets/CCPetsPhrases.h +7 -1
- package/Sources/CCPets/CCPetsPhrases.m +86 -31
- package/Sources/CCPets/CCPetsPhrasesEditor.m +62 -64
- package/Sources/CCPets/CCPetsPreviews.m +7 -6
- package/Sources/CCPets/CCPetsUsage.h +0 -1
- package/Sources/CCPets/CCPetsUsage.m +0 -3
- package/Sources/CCPets/CCPetsVersion.h +10 -0
- package/Sources/CCPets/CCPetsVersion.m +92 -2
- package/Sources/CCPets/MenuToggleSwitch.m +3 -2
- package/Sources/CCPets/PetView.h +2 -0
- package/Sources/CCPets/PetView.m +115 -74
- package/Sources/CCPets/QuotaDashboardView.m +122 -88
- package/Sources/CCPets/main.m +16 -1
- package/bin/cc-pets +25 -20
- package/bin/claude-with-pet +2 -1
- package/bin/codex-with-pet +2 -1
- package/package.json +5 -3
- package/scripts/bridge/cli.mjs +47 -39
- package/scripts/bridge/core.mjs +28 -27
- package/scripts/bridge/hook.mjs +7 -6
- package/scripts/bridge/install.mjs +42 -19
- package/scripts/bridge/mcp-server.mjs +79 -71
- package/scripts/bridge/options.mjs +7 -6
- package/scripts/bridge/process.mjs +22 -0
- package/scripts/bridge/reservations.mjs +6 -5
- package/scripts/bridge/store.mjs +10 -9
- package/scripts/build.sh +24 -5
- package/scripts/check-l10n.mjs +168 -0
- package/scripts/configure-updater.mjs +4 -3
- package/scripts/doctor.mjs +470 -0
- package/scripts/i18n.mjs +122 -0
- package/scripts/i18n.zsh +66 -0
- package/scripts/install-app.sh +3 -2
- package/scripts/install-claude-hooks.mjs +22 -27
- package/scripts/install-codex-hooks.mjs +10 -15
- package/scripts/install-shell-integration.sh +6 -5
- package/scripts/integration-markers.mjs +51 -0
- package/scripts/locales/zh-Hans.json +366 -0
- package/scripts/pet-store.mjs +47 -45
- package/scripts/uninstall-app.sh +4 -3
- package/scripts/uninstall-integrations.mjs +24 -51
- package/scripts/uninstall-shell-integration.sh +8 -7
- /package/Resources/{phrases.default.txt → phrases.default.zh-Hans.txt} +0 -0
package/Sources/CCPets/PetView.m
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#import "PetView.h"
|
|
2
|
+
#import "CCPetsL10n.h"
|
|
2
3
|
#import <QuartzCore/QuartzCore.h>
|
|
3
4
|
#import "MenuToggleSwitch.h"
|
|
4
5
|
#import "MenuHintView.h"
|
|
@@ -8,7 +9,7 @@
|
|
|
8
9
|
#import "CCPetsGlassView.h"
|
|
9
10
|
#import "MenuChoiceRow.h"
|
|
10
11
|
|
|
11
|
-
// 碎碎念频率档位的 defaults 键。定义在 CCPetsAppDelegate.m,这里只读不写;
|
|
12
|
+
// 碎碎念频率档位的 defaults 键。定义在 CCPetsAppDelegate+Speech.m,这里只读不写;
|
|
12
13
|
// 单独 extern 而不 import 那个头文件,是因为它反过来 import 了 PetView.h。
|
|
13
14
|
extern NSString *const PetSpeechFrequencyKey;
|
|
14
15
|
|
|
@@ -22,6 +23,8 @@ static const CGFloat PetDragThreshold = 3.0;
|
|
|
22
23
|
// 菜单里自绘行的宽度:主菜单要撑满 menu.minimumWidth,子菜单按自身内容收窄,
|
|
23
24
|
// 三个子菜单(用量展示模式 / 系统通知 / 系统状态)用同一个宽度,看起来才是一套。
|
|
24
25
|
static const CGFloat PetMenuRowWidth = 194.0;
|
|
26
|
+
// 两者都只是下限:译文长短差得多("等待审批" 对 "Awaiting approval"),开关行会按自己的
|
|
27
|
+
// 标题撑宽,菜单再把同一子菜单里的行统一拉到最宽那一行。
|
|
25
28
|
static const CGFloat PetSubmenuRowWidth = 134.0;
|
|
26
29
|
// 与“系统通知”里文案到开关的间距共用,素材名称到删除按钮也保持一致。
|
|
27
30
|
static const CGFloat PetMenuControlGap = 8.0;
|
|
@@ -1162,7 +1165,7 @@ typedef NS_ENUM(NSInteger, PetMicroBehaviorKind) {
|
|
|
1162
1165
|
button.bordered = confirming;
|
|
1163
1166
|
button.title = @"";
|
|
1164
1167
|
button.attributedTitle = confirming
|
|
1165
|
-
? [[NSAttributedString alloc] initWithString
|
|
1168
|
+
? [[NSAttributedString alloc] initWithString:L(@"Confirm") attributes:@{
|
|
1166
1169
|
NSFontAttributeName: [NSFont systemFontOfSize:11 weight:NSFontWeightMedium],
|
|
1167
1170
|
NSForegroundColorAttributeName: NSColor.systemRedColor,
|
|
1168
1171
|
}]
|
|
@@ -1172,7 +1175,7 @@ typedef NS_ENUM(NSInteger, PetMicroBehaviorKind) {
|
|
|
1172
1175
|
button.contentTintColor = nil;
|
|
1173
1176
|
button.bezelStyle = NSBezelStyleRounded;
|
|
1174
1177
|
button.hasDestructiveAction = YES;
|
|
1175
|
-
button.toolTip = confirming ? @"
|
|
1178
|
+
button.toolTip = confirming ? L(@"Click again to delete") : L(@"Delete pet");
|
|
1176
1179
|
[button setAccessibilityLabel:button.toolTip];
|
|
1177
1180
|
}
|
|
1178
1181
|
- (void)resetPendingDeleteButton {
|
|
@@ -1235,7 +1238,7 @@ typedef NS_ENUM(NSInteger, PetMicroBehaviorKind) {
|
|
|
1235
1238
|
BOOL deletable = [petID hasPrefix:@"external:"];
|
|
1236
1239
|
|
|
1237
1240
|
NSFont *font = [NSFont menuFontOfSize:13];
|
|
1238
|
-
CGFloat nameWidth = ceil([@"
|
|
1241
|
+
CGFloat nameWidth = ceil([L(@"Pet sprite name...") sizeWithAttributes:@{NSFontAttributeName: font}].width);
|
|
1239
1242
|
NSString *displayName = [self displayNameForPetName:name font:font maxWidth:nameWidth];
|
|
1240
1243
|
const CGFloat checkWidth = 14;
|
|
1241
1244
|
const CGFloat leadingInset = 6;
|
|
@@ -1276,7 +1279,7 @@ typedef NS_ENUM(NSInteger, PetMicroBehaviorKind) {
|
|
|
1276
1279
|
selectButton.action = @selector(selectPetFromButton:);
|
|
1277
1280
|
selectButton.focusRingType = NSFocusRingTypeNone;
|
|
1278
1281
|
selectButton.toolTip = name;
|
|
1279
|
-
[selectButton setAccessibilityLabel:[NSString stringWithFormat
|
|
1282
|
+
[selectButton setAccessibilityLabel:[NSString stringWithFormat:L(@"Switch to %@"), name]];
|
|
1280
1283
|
[row addSubview:selectButton];
|
|
1281
1284
|
|
|
1282
1285
|
NSButton *deleteButton = [[NSButton alloc] initWithFrame:NSMakeRect(deleteX, 3, deleteWidth, 22)];
|
|
@@ -1288,7 +1291,7 @@ typedef NS_ENUM(NSInteger, PetMicroBehaviorKind) {
|
|
|
1288
1291
|
deleteButton.enabled = deletable && !selected;
|
|
1289
1292
|
deleteButton.hidden = !deleteButton.enabled;
|
|
1290
1293
|
[self configureDeleteButton:deleteButton confirming:NO];
|
|
1291
|
-
deleteButton.toolTip = [NSString stringWithFormat
|
|
1294
|
+
deleteButton.toolTip = [NSString stringWithFormat:L(@"Delete %@"), name];
|
|
1292
1295
|
[deleteButton setAccessibilityLabel:deleteButton.toolTip];
|
|
1293
1296
|
[row addSubview:deleteButton];
|
|
1294
1297
|
|
|
@@ -1424,7 +1427,8 @@ typedef NS_ENUM(NSInteger, PetMicroBehaviorKind) {
|
|
|
1424
1427
|
[self.petMenuPreviewPanel orderOut:nil];
|
|
1425
1428
|
}
|
|
1426
1429
|
// 主菜单的行要撑满 menu.minimumWidth;子菜单只有自己这几项,撑到 194 会让短标题和开关
|
|
1427
|
-
//
|
|
1430
|
+
// 之间空出一大段。调用方给的是最小宽度,标题放不下时按标题撑宽;行设成可横向拉伸、
|
|
1431
|
+
// 开关贴右,菜单会把同一子菜单里的行统一拉到最宽那一行。行内边距左 12 / 右 8。
|
|
1428
1432
|
- (NSMenuItem *)addPersistentSwitchToMenu:(NSMenu *)menu
|
|
1429
1433
|
title:(NSString *)title
|
|
1430
1434
|
checked:(BOOL)checked
|
|
@@ -1434,12 +1438,16 @@ typedef NS_ENUM(NSInteger, PetMicroBehaviorKind) {
|
|
|
1434
1438
|
const CGFloat toggleWidth = 36;
|
|
1435
1439
|
const CGFloat trailingInset = PetMenuControlGap;
|
|
1436
1440
|
const CGFloat leadingInset = 12;
|
|
1441
|
+
NSTextField *label = [NSTextField labelWithString:title];
|
|
1442
|
+
label.font = [NSFont menuFontOfSize:13];
|
|
1443
|
+
width = MAX(width, ceil(label.intrinsicContentSize.width) + leadingInset + trailingInset * 2 +
|
|
1444
|
+
toggleWidth);
|
|
1437
1445
|
CGFloat toggleX = width - trailingInset - toggleWidth;
|
|
1438
1446
|
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
|
|
1439
1447
|
NSView *row = [[MenuHintRowView alloc] initWithFrame:NSMakeRect(0, 0, width, 28)];
|
|
1440
|
-
|
|
1448
|
+
row.autoresizingMask = NSViewWidthSizable;
|
|
1441
1449
|
label.frame = NSMakeRect(leadingInset, 5, toggleX - leadingInset - trailingInset, 18);
|
|
1442
|
-
label.
|
|
1450
|
+
label.autoresizingMask = NSViewWidthSizable;
|
|
1443
1451
|
label.textColor = NSColor.labelColor;
|
|
1444
1452
|
label.lineBreakMode = NSLineBreakByTruncatingTail;
|
|
1445
1453
|
[row addSubview:label];
|
|
@@ -1449,6 +1457,7 @@ typedef NS_ENUM(NSInteger, PetMicroBehaviorKind) {
|
|
|
1449
1457
|
toggle.action = action;
|
|
1450
1458
|
toggle.state = checked ? NSControlStateValueOn : NSControlStateValueOff;
|
|
1451
1459
|
toggle.tag = tag;
|
|
1460
|
+
toggle.autoresizingMask = NSViewMinXMargin;
|
|
1452
1461
|
[toggle setAccessibilityLabel:title];
|
|
1453
1462
|
[row addSubview:toggle];
|
|
1454
1463
|
item.view = row;
|
|
@@ -1473,7 +1482,7 @@ typedef NS_ENUM(NSInteger, PetMicroBehaviorKind) {
|
|
|
1473
1482
|
control.state = [[NSUserDefaults.standardUserDefaults stringForKey:preferenceKey]
|
|
1474
1483
|
isEqualToString:@"api"] ? NSControlStateValueOn : NSControlStateValueOff;
|
|
1475
1484
|
control.tag = tag;
|
|
1476
|
-
[control setAccessibilityLabel:[
|
|
1485
|
+
[control setAccessibilityLabel:[NSString stringWithFormat:L(@"%@ usage display"), provider]];
|
|
1477
1486
|
[row addSubview:control];
|
|
1478
1487
|
item.view = row;
|
|
1479
1488
|
[menu addItem:item];
|
|
@@ -1501,9 +1510,9 @@ typedef NS_ENUM(NSInteger, PetMicroBehaviorKind) {
|
|
|
1501
1510
|
bridgeMenu.delegate = self;
|
|
1502
1511
|
bridgeItem.submenu = bridgeMenu;
|
|
1503
1512
|
BOOL enabled = CCBridgeEnabled();
|
|
1504
|
-
[self addBridgeSwitchToMenu:bridgeMenu title
|
|
1513
|
+
[self addBridgeSwitchToMenu:bridgeMenu title:L(@"Enable") checked:enabled
|
|
1505
1514
|
action:@selector(toggleBridgeEnabled:) tag:0
|
|
1506
|
-
toolTip
|
|
1515
|
+
toolTip:L(@"Let local Claude Code / Codex sessions message and wake each other and reserve files")];
|
|
1507
1516
|
if (!enabled) return;
|
|
1508
1517
|
|
|
1509
1518
|
// 状态放在"启用"行的第二行,省掉底部单独的状态行和分隔线。开关上移与标题对齐,
|
|
@@ -1511,41 +1520,42 @@ typedef NS_ENUM(NSInteger, PetMicroBehaviorKind) {
|
|
|
1511
1520
|
NSDictionary *sessions = CCBridgeSessions();
|
|
1512
1521
|
NSUInteger reservations = CCBridgeActiveReservationCount([NSSet setWithArray:sessions.allKeys]);
|
|
1513
1522
|
MenuHintRowView *enableRow = (MenuHintRowView *)bridgeMenu.itemArray.lastObject.view;
|
|
1514
|
-
enableRow.hint = [enableRow.hint stringByAppendingString
|
|
1523
|
+
enableRow.hint = [enableRow.hint stringByAppendingString:L(@"\nBelow: online sessions · active file reservations")];
|
|
1515
1524
|
const CGFloat statusHeight = 14;
|
|
1516
1525
|
[enableRow setFrameSize:NSMakeSize(NSWidth(enableRow.frame), NSHeight(enableRow.frame) + statusHeight)];
|
|
1517
1526
|
for (NSView *subview in enableRow.subviews) {
|
|
1518
1527
|
[subview setFrameOrigin:NSMakePoint(NSMinX(subview.frame), NSMinY(subview.frame) + statusHeight - 2)];
|
|
1519
1528
|
}
|
|
1520
|
-
NSTextField *status = [NSTextField labelWithString:[NSString stringWithFormat
|
|
1529
|
+
NSTextField *status = [NSTextField labelWithString:[NSString stringWithFormat:L(@"%lu sessions · %lu reserved"),
|
|
1521
1530
|
(unsigned long)sessions.count, (unsigned long)reservations]];
|
|
1522
1531
|
status.frame = NSMakeRect(12, 4, NSWidth(enableRow.frame) - 12 - PetMenuControlGap, statusHeight);
|
|
1523
1532
|
status.font = [NSFont menuFontOfSize:11];
|
|
1524
1533
|
status.textColor = NSColor.secondaryLabelColor;
|
|
1525
1534
|
status.lineBreakMode = NSLineBreakByTruncatingTail;
|
|
1535
|
+
status.autoresizingMask = NSViewWidthSizable;
|
|
1526
1536
|
[enableRow addSubview:status];
|
|
1527
1537
|
|
|
1528
1538
|
[bridgeMenu addItem:NSMenuItem.separatorItem];
|
|
1529
1539
|
NSDictionary *options = CCBridgeOptions();
|
|
1530
|
-
[self addBridgeSwitchToMenu:bridgeMenu title
|
|
1540
|
+
[self addBridgeSwitchToMenu:bridgeMenu title:L(@"Auto-wake") checked:[options[@"wake"] boolValue]
|
|
1531
1541
|
action:@selector(toggleBridgeWake:) tag:0
|
|
1532
|
-
toolTip
|
|
1533
|
-
[self addBridgeSwitchToMenu:bridgeMenu title
|
|
1542
|
+
toolTip:L(@"Wake idle sessions automatically. When off, messages wait in the inbox until that session's next input, which saves tokens. Codex needs a session restart")];
|
|
1543
|
+
[self addBridgeSwitchToMenu:bridgeMenu title:L(@"Edit guard") checked:[options[@"editGuard"] boolValue]
|
|
1534
1544
|
action:@selector(toggleBridgeEditGuard:) tag:0
|
|
1535
|
-
toolTip
|
|
1545
|
+
toolTip:L(@"Pause once with an explanation when editing a file another session reserved; retrying goes through. Codex needs a session restart")];
|
|
1536
1546
|
|
|
1537
|
-
NSMenuItem *approvalItem = [bridgeMenu addItemWithTitle
|
|
1538
|
-
approvalItem.representedObject = @"
|
|
1547
|
+
NSMenuItem *approvalItem = [bridgeMenu addItemWithTitle:L(@"Auto-approve") action:nil keyEquivalent:@""];
|
|
1548
|
+
approvalItem.representedObject = L(@"Each group applies to both Codex approvals and Claude permissions. Codex needs a session restart");
|
|
1539
1549
|
NSMenu *approvalMenu = [NSMenu new];
|
|
1540
1550
|
NSArray<NSDictionary *> *groups = @[
|
|
1541
|
-
@{@"title": @"
|
|
1542
|
-
@"tip": @"
|
|
1543
|
-
@{@"title": @"
|
|
1544
|
-
@"tip": @"
|
|
1545
|
-
@{@"title": @"
|
|
1546
|
-
@"tip": @"
|
|
1547
|
-
@{@"title": @"
|
|
1548
|
-
@"tip": @"
|
|
1551
|
+
@{@"title": L(@"Read"), @"group": @"view", @"tag": @1,
|
|
1552
|
+
@"tip": L(@"Listing sessions, viewing reservations and reading the inbox. Read-only and safe")},
|
|
1553
|
+
@{@"title": L(@"Send"), @"group": @"send", @"tag": @2,
|
|
1554
|
+
@"tip": L(@"When on, Agents can message other sessions without asking")},
|
|
1555
|
+
@{@"title": L(@"Reserve"), @"group": @"reserve", @"tag": @3,
|
|
1556
|
+
@"tip": L(@"Reserving and releasing files")},
|
|
1557
|
+
@{@"title": L(@"Rename"), @"group": @"name", @"tag": @4,
|
|
1558
|
+
@"tip": L(@"Renaming the current session in CC Bridge")}
|
|
1549
1559
|
];
|
|
1550
1560
|
NSSet *codex = [NSSet setWithArray:options[@"codexApprove"]];
|
|
1551
1561
|
NSSet *claude = [NSSet setWithArray:options[@"claudeAllow"]];
|
|
@@ -1557,24 +1567,24 @@ typedef NS_ENUM(NSInteger, PetMicroBehaviorKind) {
|
|
|
1557
1567
|
}
|
|
1558
1568
|
approvalItem.submenu = approvalMenu;
|
|
1559
1569
|
|
|
1560
|
-
NSMenuItem *alertItem = [bridgeMenu addItemWithTitle
|
|
1561
|
-
alertItem.representedObject = @"
|
|
1570
|
+
NSMenuItem *alertItem = [bridgeMenu addItemWithTitle:L(@"Pet alerts") action:nil keyEquivalent:@""];
|
|
1571
|
+
alertItem.representedObject = L(@"Only affects the pet, not Claude Code / Codex settings");
|
|
1562
1572
|
NSMenu *alertMenu = [NSMenu new];
|
|
1563
|
-
[self addBridgeSwitchToMenu:alertMenu title
|
|
1573
|
+
[self addBridgeSwitchToMenu:alertMenu title:L(@"Badge")
|
|
1564
1574
|
checked:[NSUserDefaults.standardUserDefaults boolForKey:BridgeBadgeEnabledKey]
|
|
1565
1575
|
action:@selector(toggleBridgeBadge:) tag:0
|
|
1566
|
-
toolTip
|
|
1567
|
-
[self addBridgeSwitchToMenu:alertMenu title
|
|
1576
|
+
toolTip:L(@"Bottom-right of the status icon: blue for new deliveries, orange for a backed-up inbox")];
|
|
1577
|
+
[self addBridgeSwitchToMenu:alertMenu title:L(@"Notify")
|
|
1568
1578
|
checked:[NSUserDefaults.standardUserDefaults boolForKey:BridgeNotificationKey]
|
|
1569
1579
|
action:@selector(toggleBridgeNotification:) tag:0
|
|
1570
|
-
toolTip
|
|
1580
|
+
toolTip:L(@"Send a notification when a message is delivered between sessions (sender and recipient only, no content)")];
|
|
1571
1581
|
alertItem.submenu = alertMenu;
|
|
1572
1582
|
}
|
|
1573
1583
|
- (void)rightMouseDown:(NSEvent *)event {
|
|
1574
1584
|
NSArray<NSDictionary *> *availablePets = self.petOptionsRequested ? self.petOptionsRequested() : @[];
|
|
1575
1585
|
NSMenu *menu = [NSMenu new];
|
|
1576
1586
|
menu.minimumWidth = 194.0;
|
|
1577
|
-
NSMenuItem *switchItem = [menu addItemWithTitle
|
|
1587
|
+
NSMenuItem *switchItem = [menu addItemWithTitle:L(@"Pets") action:nil keyEquivalent:@""];
|
|
1578
1588
|
NSMenu *switchMenu = [NSMenu new];
|
|
1579
1589
|
switchMenu.delegate = self;
|
|
1580
1590
|
for (NSDictionary *pet in availablePets) {
|
|
@@ -1584,47 +1594,47 @@ typedef NS_ENUM(NSInteger, PetMicroBehaviorKind) {
|
|
|
1584
1594
|
switchItem.submenu = switchMenu;
|
|
1585
1595
|
[menu addItem:NSMenuItem.separatorItem];
|
|
1586
1596
|
[self addPersistentSwitchToMenu:menu
|
|
1587
|
-
title
|
|
1597
|
+
title:L(@"Show Status Card")
|
|
1588
1598
|
checked:[NSUserDefaults.standardUserDefaults boolForKey:StatusBubbleExpandedKey]
|
|
1589
1599
|
action:@selector(toggleStatusBubbleFromMenu:)
|
|
1590
1600
|
width:PetMenuRowWidth
|
|
1591
1601
|
tag:0];
|
|
1592
1602
|
[self addPersistentSwitchToMenu:menu
|
|
1593
|
-
title
|
|
1603
|
+
title:L(@"Import Codex Pets")
|
|
1594
1604
|
checked:[NSUserDefaults.standardUserDefaults boolForKey:ImportCodexPetsKey]
|
|
1595
1605
|
action:@selector(toggleImportCodexPets:)
|
|
1596
1606
|
width:PetMenuRowWidth
|
|
1597
1607
|
tag:0];
|
|
1598
|
-
NSMenuItem *usageModeItem = [menu addItemWithTitle
|
|
1608
|
+
NSMenuItem *usageModeItem = [menu addItemWithTitle:L(@"Usage Display") action:nil keyEquivalent:@""];
|
|
1599
1609
|
NSMenu *usageModeMenu = [NSMenu new];
|
|
1600
1610
|
[self addUsageModeControlToMenu:usageModeMenu provider:@"Codex"
|
|
1601
1611
|
preferenceKey:CodexUsageDisplayModeKey tag:1];
|
|
1602
1612
|
[self addUsageModeControlToMenu:usageModeMenu provider:@"Claude"
|
|
1603
1613
|
preferenceKey:ClaudeUsageDisplayModeKey tag:2];
|
|
1604
1614
|
usageModeItem.submenu = usageModeMenu;
|
|
1605
|
-
NSMenuItem *themeItem = [menu addItemWithTitle
|
|
1606
|
-
NSMenu *themeMenu = [[NSMenu alloc] initWithTitle
|
|
1615
|
+
NSMenuItem *themeItem = [menu addItemWithTitle:L(@"Panel Theme") action:nil keyEquivalent:@""];
|
|
1616
|
+
NSMenu *themeMenu = [[NSMenu alloc] initWithTitle:L(@"Panel Theme")];
|
|
1607
1617
|
// 两组都用自绘单选行:点了立即生效且菜单不收起,方便连着对比主题和压暗档位。
|
|
1608
1618
|
NSString *selectedTheme = CCPetsPanelTheme();
|
|
1609
1619
|
for (NSArray<NSString *> *option in @[
|
|
1610
|
-
@[@"
|
|
1620
|
+
@[L(@"Classic"), @"classic"], @[@"Liquid Glass", @"liquid"]]) {
|
|
1611
1621
|
NSMenuItem *item = [MenuChoiceRowView addToMenu:themeMenu title:option[0] group:@"theme"
|
|
1612
1622
|
representedObject:option[1] checked:[selectedTheme isEqualToString:option[1]]
|
|
1613
1623
|
target:NSApp.delegate action:@selector(setPanelTheme:) width:PetSubmenuRowWidth];
|
|
1614
1624
|
if ([option[1] isEqualToString:@"liquid"] && !CCPetsLiquidGlassAvailable()) {
|
|
1615
1625
|
((MenuChoiceRowView *)item.view).enabled = NO;
|
|
1616
|
-
[item.view setAccessibilityHelp
|
|
1626
|
+
[item.view setAccessibilityHelp:L(@"Requires macOS 26 or later")];
|
|
1617
1627
|
}
|
|
1618
1628
|
}
|
|
1619
1629
|
// 压暗作用于额度面板、状态卡和说话气泡的原生玻璃;经典主题下没有这层,置灰。切主题时当场联动。
|
|
1620
1630
|
[themeMenu addItem:NSMenuItem.separatorItem];
|
|
1621
|
-
NSMenuItem *dimHeader = [themeMenu addItemWithTitle
|
|
1631
|
+
NSMenuItem *dimHeader = [themeMenu addItemWithTitle:L(@"Glass Dimming") action:nil keyEquivalent:@""];
|
|
1622
1632
|
dimHeader.enabled = NO;
|
|
1623
1633
|
BOOL (^dimApplies)(void) = ^BOOL {
|
|
1624
1634
|
return [CCPetsPanelTheme() isEqualToString:@"liquid"] && CCPetsLiquidGlassAvailable();
|
|
1625
1635
|
};
|
|
1626
1636
|
NSDictionary<NSNumber *, NSString *> *dimTitles = @{
|
|
1627
|
-
@0: @"
|
|
1637
|
+
@0: L(@"Clear (0%)"), @15: L(@"Light (15%)"), @25: L(@"Standard (25%)"), @45: L(@"Legible (45%)")};
|
|
1628
1638
|
NSInteger selectedDim = CCPetsGlassDimLevel();
|
|
1629
1639
|
for (NSNumber *level in CCPetsGlassDimLevels()) {
|
|
1630
1640
|
NSMenuItem *item = [MenuChoiceRowView addToMenu:themeMenu title:dimTitles[level] group:@"dim"
|
|
@@ -1636,13 +1646,13 @@ typedef NS_ENUM(NSInteger, PetMicroBehaviorKind) {
|
|
|
1636
1646
|
row.enabled = dimApplies();
|
|
1637
1647
|
}
|
|
1638
1648
|
themeItem.submenu = themeMenu;
|
|
1639
|
-
NSMenuItem *notificationItem = [menu addItemWithTitle
|
|
1649
|
+
NSMenuItem *notificationItem = [menu addItemWithTitle:L(@"Notifications") action:nil keyEquivalent:@""];
|
|
1640
1650
|
NSMenu *notificationMenu = [NSMenu new];
|
|
1641
1651
|
NSArray<NSDictionary *> *notificationOptions = @[
|
|
1642
|
-
@{@"title": @"
|
|
1643
|
-
@{@"title": @"
|
|
1644
|
-
@{@"title": @"
|
|
1645
|
-
@{@"title": @"
|
|
1652
|
+
@{@"title": L(@"Task done"), @"key": NotificationCompletionKey, @"tag": @1},
|
|
1653
|
+
@{@"title": L(@"Task failed"), @"key": NotificationFailureKey, @"tag": @2},
|
|
1654
|
+
@{@"title": L(@"Awaiting approval"), @"key": NotificationApprovalKey, @"tag": @3},
|
|
1655
|
+
@{@"title": L(@"Stalled"), @"key": NotificationStallKey, @"tag": @4}
|
|
1646
1656
|
];
|
|
1647
1657
|
for (NSDictionary *option in notificationOptions) {
|
|
1648
1658
|
[self addPersistentSwitchToMenu:notificationMenu
|
|
@@ -1654,24 +1664,24 @@ typedef NS_ENUM(NSInteger, PetMicroBehaviorKind) {
|
|
|
1654
1664
|
}
|
|
1655
1665
|
notificationItem.submenu = notificationMenu;
|
|
1656
1666
|
[self addBridgeMenuToMenu:menu];
|
|
1657
|
-
NSMenuItem *interactionItem = [menu addItemWithTitle
|
|
1667
|
+
NSMenuItem *interactionItem = [menu addItemWithTitle:L(@"Click Reactions") action:nil keyEquivalent:@""];
|
|
1658
1668
|
NSMenu *interactionMenu = [NSMenu new];
|
|
1659
1669
|
[self addPersistentSwitchToMenu:interactionMenu
|
|
1660
|
-
title
|
|
1670
|
+
title:L(@"Enable reactions")
|
|
1661
1671
|
checked:[NSUserDefaults.standardUserDefaults boolForKey:PetInteractionEnabledKey]
|
|
1662
1672
|
action:@selector(togglePetInteraction:)
|
|
1663
1673
|
width:PetSubmenuRowWidth
|
|
1664
1674
|
tag:1];
|
|
1665
1675
|
NSArray<NSDictionary *> *interactionGroups = @[
|
|
1666
|
-
@{@"title": @"
|
|
1676
|
+
@{@"title": L(@"Hearts After"), @"key": PetInteractionHeartThresholdKey,
|
|
1667
1677
|
@"action": NSStringFromSelector(@selector(setPetInteractionHeartThreshold:)),
|
|
1668
|
-
@"values": @[@3, @5, @7], @"suffix": @"
|
|
1669
|
-
@{@"title": @"
|
|
1678
|
+
@"values": @[@3, @5, @7], @"suffix": L(@" clicks")},
|
|
1679
|
+
@{@"title": L(@"Annoyed After"), @"key": PetInteractionAnnoyedThresholdKey,
|
|
1670
1680
|
@"action": NSStringFromSelector(@selector(setPetInteractionAnnoyedThreshold:)),
|
|
1671
|
-
@"values": @[@10, @12, @15], @"suffix": @"
|
|
1672
|
-
@{@"title": @"
|
|
1681
|
+
@"values": @[@10, @12, @15], @"suffix": L(@" clicks")},
|
|
1682
|
+
@{@"title": L(@"Click Window"), @"key": PetInteractionIntervalKey,
|
|
1673
1683
|
@"action": NSStringFromSelector(@selector(setPetInteractionInterval:)),
|
|
1674
|
-
@"values": @[@0.8, @1.2, @1.8], @"suffix": @"
|
|
1684
|
+
@"values": @[@0.8, @1.2, @1.8], @"suffix": L(@" s")},
|
|
1675
1685
|
];
|
|
1676
1686
|
for (NSDictionary *group in interactionGroups) {
|
|
1677
1687
|
NSMenuItem *groupItem = [interactionMenu addItemWithTitle:group[@"title"]
|
|
@@ -1693,16 +1703,16 @@ typedef NS_ENUM(NSInteger, PetMicroBehaviorKind) {
|
|
|
1693
1703
|
groupItem.submenu = options;
|
|
1694
1704
|
}
|
|
1695
1705
|
[interactionMenu addItem:NSMenuItem.separatorItem];
|
|
1696
|
-
NSMenuItem *editInteractionPhrases = [interactionMenu addItemWithTitle
|
|
1706
|
+
NSMenuItem *editInteractionPhrases = [interactionMenu addItemWithTitle:L(@"Edit Reaction Lines…")
|
|
1697
1707
|
action:@selector(editPhrasesFile:) keyEquivalent:@""];
|
|
1698
1708
|
editInteractionPhrases.target = NSApp.delegate;
|
|
1699
1709
|
interactionItem.submenu = interactionMenu;
|
|
1700
|
-
NSMenuItem *systemStatusItem = [menu addItemWithTitle
|
|
1710
|
+
NSMenuItem *systemStatusItem = [menu addItemWithTitle:L(@"System Status") action:nil keyEquivalent:@""];
|
|
1701
1711
|
NSMenu *systemStatusMenu = [NSMenu new];
|
|
1702
1712
|
NSArray<NSDictionary *> *systemStatusOptions = @[
|
|
1703
|
-
@{@"title": @"CPU
|
|
1704
|
-
@{@"title": @"CPU
|
|
1705
|
-
@{@"title": @"
|
|
1713
|
+
@{@"title": L(@"CPU usage"), @"key": SystemCPUEnabledKey, @"tag": @1},
|
|
1714
|
+
@{@"title": L(@"CPU temp"), @"key": SystemTemperatureEnabledKey, @"tag": @2},
|
|
1715
|
+
@{@"title": L(@"Memory"), @"key": SystemMemoryEnabledKey, @"tag": @3}
|
|
1706
1716
|
];
|
|
1707
1717
|
for (NSDictionary *option in systemStatusOptions) {
|
|
1708
1718
|
[self addPersistentSwitchToMenu:systemStatusMenu
|
|
@@ -1713,11 +1723,11 @@ typedef NS_ENUM(NSInteger, PetMicroBehaviorKind) {
|
|
|
1713
1723
|
tag:[option[@"tag"] integerValue]];
|
|
1714
1724
|
}
|
|
1715
1725
|
systemStatusItem.submenu = systemStatusMenu;
|
|
1716
|
-
NSMenuItem *speechItem = [menu addItemWithTitle
|
|
1726
|
+
NSMenuItem *speechItem = [menu addItemWithTitle:L(@"Chatter") action:nil keyEquivalent:@""];
|
|
1717
1727
|
NSMenu *speechMenu = [NSMenu new];
|
|
1718
1728
|
id speechValue = [NSUserDefaults.standardUserDefaults objectForKey:@"CCPetsSpeechEnabled"];
|
|
1719
1729
|
[self addPersistentSwitchToMenu:speechMenu
|
|
1720
|
-
title
|
|
1730
|
+
title:L(@"Enable chatter")
|
|
1721
1731
|
checked:speechValue == nil ? YES : [speechValue boolValue]
|
|
1722
1732
|
action:@selector(toggleSpeech:)
|
|
1723
1733
|
width:PetSubmenuRowWidth
|
|
@@ -1725,15 +1735,15 @@ typedef NS_ENUM(NSInteger, PetMicroBehaviorKind) {
|
|
|
1725
1735
|
// 频率是四道闸的组合,单调任何一道都不会真的变频繁,所以只给一个档位。
|
|
1726
1736
|
// 用系统的打勾单选行,不用自绘开关:这几项互斥,开关会看起来像四个独立选项。
|
|
1727
1737
|
[speechMenu addItem:NSMenuItem.separatorItem];
|
|
1728
|
-
NSMenuItem *frequencyHeader = [speechMenu addItemWithTitle
|
|
1738
|
+
NSMenuItem *frequencyHeader = [speechMenu addItemWithTitle:L(@"Frequency") action:nil keyEquivalent:@""];
|
|
1729
1739
|
frequencyHeader.enabled = NO;
|
|
1730
1740
|
NSString *frequency = [NSUserDefaults.standardUserDefaults
|
|
1731
1741
|
stringForKey:PetSpeechFrequencyKey] ?: @"normal";
|
|
1732
1742
|
NSArray<NSDictionary *> *frequencyOptions = @[
|
|
1733
|
-
@{@"title": @"
|
|
1734
|
-
@{@"title": @"
|
|
1735
|
-
@{@"title": @"
|
|
1736
|
-
@{@"title": @"
|
|
1743
|
+
@{@"title": L(@"Rarely"), @"value": @"low"},
|
|
1744
|
+
@{@"title": L(@"Normal"), @"value": @"normal"},
|
|
1745
|
+
@{@"title": L(@"Often"), @"value": @"high"},
|
|
1746
|
+
@{@"title": L(@"Chatty"), @"value": @"chatty"},
|
|
1737
1747
|
];
|
|
1738
1748
|
for (NSDictionary *option in frequencyOptions) {
|
|
1739
1749
|
NSMenuItem *item = [speechMenu addItemWithTitle:option[@"title"]
|
|
@@ -1746,16 +1756,47 @@ typedef NS_ENUM(NSInteger, PetMicroBehaviorKind) {
|
|
|
1746
1756
|
}
|
|
1747
1757
|
[speechMenu addItem:NSMenuItem.separatorItem];
|
|
1748
1758
|
// 没有这个入口,九成用户不会知道台词可以自己改。
|
|
1749
|
-
NSMenuItem *editPhrases = [speechMenu addItemWithTitle
|
|
1759
|
+
NSMenuItem *editPhrases = [speechMenu addItemWithTitle:L(@"Edit Lines…")
|
|
1750
1760
|
action:@selector(editPhrasesFile:) keyEquivalent:@""];
|
|
1751
1761
|
editPhrases.target = NSApp.delegate;
|
|
1752
1762
|
speechItem.submenu = speechMenu;
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1763
|
+
// 检查更新和关于收进「帮助」;有新版本时在顶层临时多一项「更新到 x.y.z…」,一步就能更新,
|
|
1764
|
+
// 不必展开子菜单。气泡和角标错过了,这里仍是醒目的入口。
|
|
1765
|
+
NSString *pendingVersion = self.pendingUpdateVersionRequested ? self.pendingUpdateVersionRequested() : nil;
|
|
1766
|
+
if (pendingVersion.length > 0) {
|
|
1767
|
+
NSMenuItem *installItem = [menu addItemWithTitle:
|
|
1768
|
+
[NSString stringWithFormat:L(@"Update to %@…"), pendingVersion]
|
|
1769
|
+
action:@selector(showPendingUpdate:) keyEquivalent:@""];
|
|
1770
|
+
installItem.target = NSApp.delegate;
|
|
1771
|
+
}
|
|
1772
|
+
// 语言名用各自的写法,不跟着界面语言翻译:切错了语言的人也要认得出回去的那一项。
|
|
1773
|
+
NSMenuItem *languageItem = [menu addItemWithTitle:L(@"Language") action:nil keyEquivalent:@""];
|
|
1774
|
+
NSMenu *languageMenu = [NSMenu new];
|
|
1775
|
+
NSString *languagePreference = CCPetsLanguagePreference();
|
|
1776
|
+
NSMutableArray<NSArray<NSString *> *> *languageOptions =
|
|
1777
|
+
[NSMutableArray arrayWithObject:@[L(@"System Default"), CCPetsLanguageSystem]];
|
|
1778
|
+
// 有哪些语言由打包进来的 .lproj 决定,加一种语言不用改这里。
|
|
1779
|
+
for (NSString *language in CCPetsSupportedLanguages()) {
|
|
1780
|
+
[languageOptions addObject:@[CCPetsLanguageDisplayName(language), language]];
|
|
1781
|
+
}
|
|
1782
|
+
for (NSArray<NSString *> *option in languageOptions) {
|
|
1783
|
+
NSMenuItem *item = [languageMenu addItemWithTitle:option[0]
|
|
1784
|
+
action:@selector(setLanguagePreferenceFromMenu:) keyEquivalent:@""];
|
|
1785
|
+
item.target = NSApp.delegate;
|
|
1786
|
+
item.representedObject = option[1];
|
|
1787
|
+
item.state = [languagePreference isEqualToString:option[1]] ?
|
|
1788
|
+
NSControlStateValueOn : NSControlStateValueOff;
|
|
1789
|
+
}
|
|
1790
|
+
languageItem.submenu = languageMenu;
|
|
1791
|
+
NSMenuItem *helpItem = [menu addItemWithTitle:L(@"Help") action:nil keyEquivalent:@""];
|
|
1792
|
+
NSMenu *helpMenu = [NSMenu new];
|
|
1793
|
+
NSMenuItem *updateItem = [helpMenu addItemWithTitle:L(@"Check for Updates…") action:@selector(checkForUpdates:) keyEquivalent:@""];
|
|
1756
1794
|
updateItem.target = NSApp.delegate;
|
|
1795
|
+
NSMenuItem *aboutItem = [helpMenu addItemWithTitle:L(@"About CC Pets") action:@selector(showAboutPanel:) keyEquivalent:@""];
|
|
1796
|
+
aboutItem.target = NSApp.delegate;
|
|
1797
|
+
helpItem.submenu = helpMenu;
|
|
1757
1798
|
[menu addItem:NSMenuItem.separatorItem];
|
|
1758
|
-
NSMenuItem *quitItem = [menu addItemWithTitle
|
|
1799
|
+
NSMenuItem *quitItem = [menu addItemWithTitle:L(@"Quit CC Pets") action:@selector(terminate:) keyEquivalent:@"q"];
|
|
1759
1800
|
quitItem.target = NSApp;
|
|
1760
1801
|
[NSMenu popUpContextMenu:menu withEvent:event forView:self];
|
|
1761
1802
|
[MenuHint cancel];
|