cc-pets 2.1.2 → 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/CHANGELOG.md +17 -0
- package/CHANGELOG.zh-CN.md +17 -0
- package/CONTRIBUTING.md +54 -0
- package/CONTRIBUTING.zh-CN.md +45 -0
- package/README.md +31 -26
- package/README.zh-CN.md +22 -16
- 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+AgentStatus.m +28 -28
- package/Sources/CCPets/CCPetsAppDelegate+Bridge.m +16 -14
- package/Sources/CCPets/CCPetsAppDelegate+Pets.m +7 -9
- package/Sources/CCPets/CCPetsAppDelegate+Private.h +3 -0
- package/Sources/CCPets/CCPetsAppDelegate+Settings.m +25 -4
- package/Sources/CCPets/CCPetsAppDelegate+Speech.m +1 -1
- package/Sources/CCPets/CCPetsAppDelegate+Update.m +36 -35
- package/Sources/CCPets/CCPetsAppDelegate.m +20 -14
- package/Sources/CCPets/CCPetsCleanup.m +9 -6
- package/Sources/CCPets/CCPetsEvents.m +4 -3
- package/Sources/CCPets/CCPetsL10n.h +55 -0
- package/Sources/CCPets/CCPetsL10n.m +219 -0
- 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/CCPetsVersion.h +7 -4
- package/Sources/CCPets/CCPetsVersion.m +14 -6
- package/Sources/CCPets/MenuToggleSwitch.m +3 -2
- package/Sources/CCPets/PetView.m +103 -74
- package/Sources/CCPets/QuotaDashboardView.m +122 -85
- package/Sources/CCPets/main.m +3 -1
- package/bin/cc-pets +21 -22
- package/bin/claude-with-pet +2 -1
- package/bin/codex-with-pet +2 -1
- package/package.json +3 -2
- package/scripts/bridge/cli.mjs +39 -38
- package/scripts/bridge/core.mjs +27 -26
- package/scripts/bridge/hook.mjs +7 -6
- package/scripts/bridge/install.mjs +24 -23
- package/scripts/bridge/mcp-server.mjs +79 -71
- package/scripts/bridge/options.mjs +7 -6
- 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 +93 -79
- 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 +10 -9
- package/scripts/install-codex-hooks.mjs +7 -6
- package/scripts/install-shell-integration.sh +6 -5
- package/scripts/locales/zh-Hans.json +366 -0
- package/scripts/pet-store.mjs +45 -44
- package/scripts/uninstall-app.sh +4 -3
- package/scripts/uninstall-integrations.mjs +8 -7
- package/scripts/uninstall-shell-integration.sh +8 -7
- /package/Resources/{phrases.default.txt → phrases.default.zh-Hans.txt} +0 -0
|
@@ -80,7 +80,7 @@ void PetPhrasesSetCurrentPetID(NSString *petID);
|
|
|
80
80
|
NSString *PetPhrasesCurrentPetID(void);
|
|
81
81
|
// 当前宠物的专属词库路径。还没设过宠物时返回 nil。
|
|
82
82
|
NSString *PetPhrasesCurrentPetFilePath(void);
|
|
83
|
-
// 默认词库路径:app bundle
|
|
83
|
+
// 默认词库路径:app bundle 里当前语言的 phrases.default.<语言>.txt,没有就用英文那份。
|
|
84
84
|
// 可用 CC_PETS_PHRASES_DEFAULT_FILE 覆盖(测试用)。
|
|
85
85
|
NSString *PetPhrasesDefaultFilePath(void);
|
|
86
86
|
// 用户词库不存在就从默认词库拷一份出来。返回是否可用。
|
|
@@ -89,6 +89,9 @@ NSString *PetPhrasesDefaultFilePath(void);
|
|
|
89
89
|
// 这一刻出现一次,之后运行时只认用户文件。两份词库同时存在于运行期就必然要回答
|
|
90
90
|
// "以谁为准",那正是 merge/replace 那套让人看不懂的根源。
|
|
91
91
|
BOOL PetPhrasesEnsureFileExists(void);
|
|
92
|
+
// 用户词库和"另一种语言"的默认词库一字不差(也就是从没改过)时,换成当前语言的默认词库。
|
|
93
|
+
// 改过一个字都不动:那是用户自己的台词,语言切换不该替他做主。返回是否替换了。
|
|
94
|
+
BOOL PetPhrasesAdoptLanguageDefaults(void);
|
|
92
95
|
// 给升级用户补一次新加入的连击互动小节;已有小节(包括用户主动留空)绝不覆盖。
|
|
93
96
|
BOOL PetPhrasesEnsureInteractionSections(void);
|
|
94
97
|
|
|
@@ -104,7 +107,10 @@ NSArray<NSString *> *PetPhraseSlotNames(void);
|
|
|
104
107
|
|
|
105
108
|
// 单条模板的长度上限(字符)。超了直接丢弃——气泡布局撑不下,
|
|
106
109
|
// 与其截断出半句话不如不说。
|
|
110
|
+
// 含中日韩字符的句子按 PetPhraseMaxLength,纯拉丁文字的按 PetPhraseMaxLatinLength。
|
|
107
111
|
extern const NSUInteger PetPhraseMaxLength;
|
|
112
|
+
extern const NSUInteger PetPhraseMaxLatinLength;
|
|
113
|
+
NSUInteger PetPhraseMaxLengthForText(NSString *text);
|
|
108
114
|
|
|
109
115
|
// 校验结果的一条。
|
|
110
116
|
typedef NS_ENUM(NSInteger, PetPhraseIssueLevel) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#import "CCPetsPhrases.h"
|
|
2
|
+
#import "CCPetsL10n.h"
|
|
2
3
|
|
|
3
4
|
NSString *const PetPhraseTagDone = @"done";
|
|
4
5
|
NSString *const PetPhraseTagFail = @"fail";
|
|
@@ -27,6 +28,26 @@ NSString *const PetPhraseTagStateFailed = @"state_failed";
|
|
|
27
28
|
NSString *const PetPhraseTagStateNotification = @"state_notification";
|
|
28
29
|
|
|
29
30
|
const NSUInteger PetPhraseMaxLength = 30;
|
|
31
|
+
const NSUInteger PetPhraseMaxLatinLength = 40;
|
|
32
|
+
|
|
33
|
+
// 气泡最宽 300pt、13pt 字号:汉字一个顶一个字宽,30 个刚好;英文字母大约半个字宽,
|
|
34
|
+
// 同样宽度能放 40 个上下。按"有没有中日韩字符"二选一,不做逐字加权——加权之后用户
|
|
35
|
+
// 没法对着报错数出自己超了多少。
|
|
36
|
+
NSUInteger PetPhraseMaxLengthForText(NSString *text) {
|
|
37
|
+
static NSCharacterSet *wide;
|
|
38
|
+
static dispatch_once_t once;
|
|
39
|
+
dispatch_once(&once, ^{
|
|
40
|
+
NSMutableCharacterSet *set = [NSMutableCharacterSet new];
|
|
41
|
+
[set addCharactersInRange:NSMakeRange(0x1100, 0x0100)]; // 谚文字母
|
|
42
|
+
[set addCharactersInRange:NSMakeRange(0x2E80, 0xA4D0 - 0x2E80)]; // 中日韩部首到彝文
|
|
43
|
+
[set addCharactersInRange:NSMakeRange(0xAC00, 0xD7A4 - 0xAC00)]; // 谚文音节
|
|
44
|
+
[set addCharactersInRange:NSMakeRange(0xF900, 0x0200)]; // 兼容汉字
|
|
45
|
+
[set addCharactersInRange:NSMakeRange(0xFF00, 0x0061)]; // 全角 ASCII
|
|
46
|
+
wide = set;
|
|
47
|
+
});
|
|
48
|
+
return [text rangeOfCharacterFromSet:wide].location == NSNotFound
|
|
49
|
+
? PetPhraseMaxLatinLength : PetPhraseMaxLength;
|
|
50
|
+
}
|
|
30
51
|
// 最近说过的这么多条不再重复。模板库不大,靠这个把主观重复感压下去。
|
|
31
52
|
static const NSUInteger PetPhraseRecentMemory = 12;
|
|
32
53
|
|
|
@@ -118,16 +139,49 @@ NSString *PetPhrasesCurrentPetFilePath(void) {
|
|
|
118
139
|
return PetPhrasesFilePathForPetID(PetPhrasesCurrentPet);
|
|
119
140
|
}
|
|
120
141
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
NSString *bundled = [NSBundle.mainBundle pathForResource:@"
|
|
125
|
-
ofType:@"txt"];
|
|
142
|
+
// 每种界面语言一份默认词库:phrases.default.<语言>.txt(zh-Hans、en…)。找不到返回 nil。
|
|
143
|
+
static NSString *PetPhrasesBundledDefaultPath(NSString *language) {
|
|
144
|
+
NSString *name = [@"phrases.default." stringByAppendingString:language];
|
|
145
|
+
NSString *bundled = [NSBundle.mainBundle pathForResource:name ofType:@"txt"];
|
|
126
146
|
if (bundled.length > 0) return bundled;
|
|
127
147
|
// 直接跑 .build/release/cc-pets(没有 app bundle)时退到可执行文件旁边,
|
|
128
148
|
// 否则开发期跑起来一句台词都没有,会被误当成解析出了问题。
|
|
129
149
|
NSString *executable = NSBundle.mainBundle.executablePath.stringByDeletingLastPathComponent;
|
|
130
|
-
|
|
150
|
+
NSString *path = [executable stringByAppendingPathComponent:
|
|
151
|
+
[name stringByAppendingPathExtension:@"txt"]];
|
|
152
|
+
return [NSFileManager.defaultManager fileExistsAtPath:path] ? path : nil;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// 当前语言没有默认台词(翻译只做了界面)时退回源语言那份。
|
|
156
|
+
NSString *PetPhrasesDefaultFilePath(void) {
|
|
157
|
+
NSString *override = NSProcessInfo.processInfo.environment[@"CC_PETS_PHRASES_DEFAULT_FILE"];
|
|
158
|
+
if (override.length > 0) return override.stringByStandardizingPath;
|
|
159
|
+
NSString *path = PetPhrasesBundledDefaultPath(CCPetsCurrentLanguage()) ?:
|
|
160
|
+
PetPhrasesBundledDefaultPath(CCPetsSourceLanguage);
|
|
161
|
+
if (path.length > 0) return path;
|
|
162
|
+
NSString *executable = NSBundle.mainBundle.executablePath.stringByDeletingLastPathComponent;
|
|
163
|
+
return [executable stringByAppendingPathComponent:
|
|
164
|
+
[NSString stringWithFormat:@"phrases.default.%@.txt", CCPetsSourceLanguage]];
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
BOOL PetPhrasesAdoptLanguageDefaults(void) {
|
|
168
|
+
// 测试指定了默认词库时只有那一份,没有"另一种语言"可比。
|
|
169
|
+
if (NSProcessInfo.processInfo.environment[@"CC_PETS_PHRASES_DEFAULT_FILE"].length > 0) return NO;
|
|
170
|
+
NSString *path = PetPhrasesFilePath();
|
|
171
|
+
NSString *text = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
|
|
172
|
+
NSString *currentPath = PetPhrasesDefaultFilePath();
|
|
173
|
+
NSString *currentText = [NSString stringWithContentsOfFile:currentPath
|
|
174
|
+
encoding:NSUTF8StringEncoding error:nil];
|
|
175
|
+
if (text.length == 0 || currentText.length == 0 || [text isEqualToString:currentText]) return NO;
|
|
176
|
+
for (NSString *language in CCPetsSupportedLanguages()) {
|
|
177
|
+
NSString *otherPath = PetPhrasesBundledDefaultPath(language);
|
|
178
|
+
if (otherPath.length == 0 || [otherPath isEqualToString:currentPath]) continue;
|
|
179
|
+
NSString *otherText = [NSString stringWithContentsOfFile:otherPath
|
|
180
|
+
encoding:NSUTF8StringEncoding error:nil];
|
|
181
|
+
if (![text isEqualToString:otherText]) continue;
|
|
182
|
+
return [currentText writeToFile:path atomically:YES encoding:NSUTF8StringEncoding error:nil];
|
|
183
|
+
}
|
|
184
|
+
return NO;
|
|
131
185
|
}
|
|
132
186
|
|
|
133
187
|
BOOL PetPhrasesEnsureFileExists(void) {
|
|
@@ -178,20 +232,20 @@ NSString *PetPhraseTagDescription(NSString *tag) {
|
|
|
178
232
|
static dispatch_once_t once;
|
|
179
233
|
dispatch_once(&once, ^{
|
|
180
234
|
map = @{
|
|
181
|
-
PetPhraseTagIdle: @"
|
|
182
|
-
PetPhraseTagFail: @"
|
|
183
|
-
PetPhraseTagLateNight: @"
|
|
184
|
-
PetPhraseTagQuotaLow: @"
|
|
185
|
-
PetPhraseTagClickHeart: @"
|
|
186
|
-
PetPhraseTagClickAnnoyed: @"
|
|
187
|
-
PetPhraseTagStateStarting: @"
|
|
188
|
-
PetPhraseTagStateThinking: @"
|
|
189
|
-
PetPhraseTagStateToolBash: @"
|
|
190
|
-
PetPhraseTagStateToolRead: @"
|
|
191
|
-
PetPhraseTagStateToolFailed: @"
|
|
192
|
-
PetPhraseTagStateApproval: @"
|
|
193
|
-
PetPhraseTagStateCompleted: @"
|
|
194
|
-
PetPhraseTagStateNotification: @"
|
|
235
|
+
PetPhraseTagIdle: L(@"idle"), PetPhraseTagDone: L(@"Task done"),
|
|
236
|
+
PetPhraseTagFail: L(@"repeated failures"), PetPhraseTagWake: L(@"back after a long break"),
|
|
237
|
+
PetPhraseTagLateNight: L(@"working late at night"), PetPhraseTagLongSession: L(@"long session"),
|
|
238
|
+
PetPhraseTagQuotaLow: L(@"quota running low"),
|
|
239
|
+
PetPhraseTagClickHeart: L(@"happy after a few clicks"),
|
|
240
|
+
PetPhraseTagClickAnnoyed: L(@"annoyed after too many clicks"),
|
|
241
|
+
PetPhraseTagStateStarting: L(@"Starting"), PetPhraseTagStateIdle: L(@"Idle"),
|
|
242
|
+
PetPhraseTagStateThinking: L(@"Thinking"), PetPhraseTagStateTool: L(@"using a tool"),
|
|
243
|
+
PetPhraseTagStateToolBash: L(@"Running a command"), PetPhraseTagStateToolEdit: L(@"Editing files"),
|
|
244
|
+
PetPhraseTagStateToolRead: L(@"Looking things up"), PetPhraseTagStateToolDone: L(@"step done"),
|
|
245
|
+
PetPhraseTagStateToolFailed: L(@"Tool failed"), PetPhraseTagStateSubagent: L(@"Subagent working"),
|
|
246
|
+
PetPhraseTagStateApproval: L(@"Awaiting approval"), PetPhraseTagStateAutoReview: L(@"Auto-reviewing"),
|
|
247
|
+
PetPhraseTagStateCompleted: L(@"Task completed"), PetPhraseTagStateFailed: L(@"Task failed"),
|
|
248
|
+
PetPhraseTagStateNotification: L(@"Needs attention"),
|
|
195
249
|
};
|
|
196
250
|
});
|
|
197
251
|
return map[tag] ?: tag;
|
|
@@ -241,8 +295,8 @@ static void FlushOrphans(void (^onDrop)(NSInteger line, NSString *reason),
|
|
|
241
295
|
NSInteger *start, NSInteger *count) {
|
|
242
296
|
if (*count == 0) return;
|
|
243
297
|
if (onDrop) {
|
|
244
|
-
onDrop(*start, *count == 1 ? @"
|
|
245
|
-
[NSString stringWithFormat
|
|
298
|
+
onDrop(*start, *count == 1 ? L(@"This line isn't under any [tag] and won't be used") :
|
|
299
|
+
[NSString stringWithFormat:L(@"%ld lines here aren't under any [tag] and won't be used"),
|
|
246
300
|
(long)*count]);
|
|
247
301
|
}
|
|
248
302
|
*count = 0;
|
|
@@ -277,7 +331,7 @@ static NSDictionary<NSString *, NSArray<NSString *> *> *ParsePhrasesText(NSStrin
|
|
|
277
331
|
current = nil;
|
|
278
332
|
insideUnknownSection = YES;
|
|
279
333
|
if (onDrop) onDrop(lineNumber,
|
|
280
|
-
[NSString stringWithFormat
|
|
334
|
+
[NSString stringWithFormat:L(@"There's no [%@] tag; the lines below won't be used"), tag]);
|
|
281
335
|
continue;
|
|
282
336
|
}
|
|
283
337
|
insideUnknownSection = NO;
|
|
@@ -293,10 +347,11 @@ static NSDictionary<NSString *, NSArray<NSString *> *> *ParsePhrasesText(NSStrin
|
|
|
293
347
|
}
|
|
294
348
|
continue;
|
|
295
349
|
}
|
|
296
|
-
|
|
350
|
+
NSUInteger maxLength = PetPhraseMaxLengthForText(line);
|
|
351
|
+
if (line.length > maxLength) {
|
|
297
352
|
if (onDrop) onDrop(lineNumber, [NSString stringWithFormat:
|
|
298
|
-
@"
|
|
299
|
-
(unsigned long)
|
|
353
|
+
L(@"This line has %lu characters, over the %lu limit"), (unsigned long)line.length,
|
|
354
|
+
(unsigned long)maxLength]);
|
|
300
355
|
continue;
|
|
301
356
|
}
|
|
302
357
|
[groups[current] addObject:line];
|
|
@@ -413,7 +468,7 @@ static NSArray<NSString *> *CandidatesForTag(NSString *tag) {
|
|
|
413
468
|
// 解析时已逐行校验过,这里再挡一道,防止将来换了来源出岔子。
|
|
414
469
|
if (![entry isKindOfClass:NSString.class]) continue;
|
|
415
470
|
NSString *text = entry;
|
|
416
|
-
if (text.length == 0 || text.length >
|
|
471
|
+
if (text.length == 0 || text.length > PetPhraseMaxLengthForText(text)) continue;
|
|
417
472
|
[result addObject:text];
|
|
418
473
|
}
|
|
419
474
|
return result;
|
|
@@ -634,7 +689,7 @@ static NSArray<PetPhraseIssue *> *ValidateText(NSString *text, BOOL forPet) {
|
|
|
634
689
|
NSString *name = [line substringWithRange:[match rangeAtIndex:1]];
|
|
635
690
|
if ([slots containsObject:name]) continue;
|
|
636
691
|
[issues addObject:MakeIssue((NSInteger)index + 1, PetPhraseIssueLevelWarning,
|
|
637
|
-
[NSString stringWithFormat
|
|
692
|
+
[NSString stringWithFormat:L(@"{%@} isn't a known placeholder; this line will never be said"), name])];
|
|
638
693
|
}
|
|
639
694
|
}
|
|
640
695
|
|
|
@@ -652,17 +707,17 @@ static NSArray<PetPhraseIssue *> *ValidateText(NSString *text, BOOL forPet) {
|
|
|
652
707
|
NSArray *entries = groups[tag];
|
|
653
708
|
if (entries == nil) {
|
|
654
709
|
[issues addObject:MakeIssue(0, PetPhraseIssueLevelError, [NSString stringWithFormat:
|
|
655
|
-
@"
|
|
710
|
+
L(@"The [%1$@] (%2$@) line is missing. Tags can't be deleted; add it back (it can stay empty)"),
|
|
656
711
|
tag, PetPhraseTagDescription(tag)])];
|
|
657
712
|
continue;
|
|
658
713
|
}
|
|
659
714
|
if (entries.count > 0) continue;
|
|
660
715
|
if ([stateTags containsObject:tag]) {
|
|
661
716
|
[issues addObject:MakeIssue(0, PetPhraseIssueLevelError, [NSString stringWithFormat:
|
|
662
|
-
@"[
|
|
717
|
+
L(@"[%1$@] (%2$@) needs at least one line"), tag, PetPhraseTagDescription(tag)])];
|
|
663
718
|
} else {
|
|
664
719
|
[issues addObject:MakeIssue(0, PetPhraseIssueLevelWarning, [NSString stringWithFormat:
|
|
665
|
-
@"[
|
|
720
|
+
L(@"[%1$@] (%2$@) is empty; the pet will stay quiet here"), tag, PetPhraseTagDescription(tag)])];
|
|
666
721
|
}
|
|
667
722
|
}
|
|
668
723
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#import "CCPetsPhrasesEditor.h"
|
|
2
|
+
#import "CCPetsL10n.h"
|
|
2
3
|
#import "CCPetsPhrases.h"
|
|
3
4
|
|
|
4
5
|
static void (^PetPhrasesSpeakHandler)(NSString *);
|
|
@@ -56,7 +57,7 @@ static void (^PetPhrasesSpeakHandler)(NSString *);
|
|
|
56
57
|
styleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable |
|
|
57
58
|
NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable
|
|
58
59
|
backing:NSBackingStoreBuffered defer:NO];
|
|
59
|
-
window.title = @"
|
|
60
|
+
window.title = L(@"Pet Lines");
|
|
60
61
|
window.releasedWhenClosed = NO;
|
|
61
62
|
window.minSize = NSMakeSize(460, 400);
|
|
62
63
|
[window center];
|
|
@@ -101,37 +102,37 @@ static void (^PetPhrasesSpeakHandler)(NSString *);
|
|
|
101
102
|
NSPopUpButton *picker = [[NSPopUpButton alloc] initWithFrame:NSZeroRect pullsDown:NO];
|
|
102
103
|
picker.translatesAutoresizingMaskIntoConstraints = NO;
|
|
103
104
|
for (NSString *tag in PetPhraseAllTags()) {
|
|
104
|
-
[picker addItemWithTitle:[NSString stringWithFormat
|
|
105
|
+
[picker addItemWithTitle:[NSString stringWithFormat:L(@"%1$@ (%2$@)"),
|
|
105
106
|
PetPhraseTagDescription(tag), tag]];
|
|
106
107
|
picker.lastItem.representedObject = tag;
|
|
107
108
|
}
|
|
108
109
|
self.tagPicker = picker;
|
|
109
110
|
|
|
110
|
-
NSButton *speak = [NSButton buttonWithTitle
|
|
111
|
+
NSButton *speak = [NSButton buttonWithTitle:L(@"Try a Line") target:self
|
|
111
112
|
action:@selector(speakSample:)];
|
|
112
113
|
speak.translatesAutoresizingMaskIntoConstraints = NO;
|
|
113
114
|
|
|
114
|
-
NSButton *save = [NSButton buttonWithTitle
|
|
115
|
+
NSButton *save = [NSButton buttonWithTitle:L(@"Save") target:self action:@selector(save:)];
|
|
115
116
|
// ⌘S 而不是回车:这是个多行文本编辑器,回车要用来换行。
|
|
116
117
|
save.keyEquivalent = @"s";
|
|
117
118
|
save.keyEquivalentModifierMask = NSEventModifierFlagCommand;
|
|
118
119
|
save.translatesAutoresizingMaskIntoConstraints = NO;
|
|
119
120
|
self.saveButton = save;
|
|
120
121
|
|
|
121
|
-
NSButton *saveAndClose = [NSButton buttonWithTitle
|
|
122
|
+
NSButton *saveAndClose = [NSButton buttonWithTitle:L(@"Save & Close") target:self
|
|
122
123
|
action:@selector(saveAndClose:)];
|
|
123
124
|
saveAndClose.keyEquivalent = @"\r";
|
|
124
125
|
saveAndClose.translatesAutoresizingMaskIntoConstraints = NO;
|
|
125
126
|
self.saveAndCloseButton = saveAndClose;
|
|
126
127
|
|
|
127
|
-
NSButton *revert = [NSButton buttonWithTitle
|
|
128
|
+
NSButton *revert = [NSButton buttonWithTitle:L(@"Restore Defaults…") target:self
|
|
128
129
|
action:@selector(revertToDefault:)];
|
|
129
130
|
revert.translatesAutoresizingMaskIntoConstraints = NO;
|
|
130
131
|
self.revertButton = revert;
|
|
131
132
|
|
|
132
133
|
// 两段式而不是下拉菜单:一共就两个去处,而且"我现在改的是哪一份"必须一眼可见——
|
|
133
134
|
// 藏进下拉里的话,用户很容易把只想给一只宠物写的台词存进通用词库。
|
|
134
|
-
NSSegmentedControl *scope = [NSSegmentedControl segmentedControlWithLabels:@[@"
|
|
135
|
+
NSSegmentedControl *scope = [NSSegmentedControl segmentedControlWithLabels:@[L(@"Shared"), L(@"This Pet")]
|
|
135
136
|
trackingMode:NSSegmentSwitchTrackingSelectOne target:self action:@selector(scopeChanged:)];
|
|
136
137
|
scope.translatesAutoresizingMaskIntoConstraints = NO;
|
|
137
138
|
scope.selectedSegment = 0;
|
|
@@ -140,7 +141,7 @@ static void (^PetPhrasesSpeakHandler)(NSString *);
|
|
|
140
141
|
// 专属页初次打开是空白的——空白在语义上是对的(全部回落到通用),但一个空白文本框
|
|
141
142
|
// 不告诉任何人该往里写什么。这个按钮就是那个起点:把默认台词整份填进来,
|
|
142
143
|
// 用户在上面改字、删掉不想接管的小节即可。
|
|
143
|
-
NSButton *fill = [NSButton buttonWithTitle
|
|
144
|
+
NSButton *fill = [NSButton buttonWithTitle:L(@"Insert Template") target:self
|
|
144
145
|
action:@selector(fillFromDefault:)];
|
|
145
146
|
fill.translatesAutoresizingMaskIntoConstraints = NO;
|
|
146
147
|
fill.hidden = YES;
|
|
@@ -206,8 +207,8 @@ static void (^PetPhrasesSpeakHandler)(NSString *);
|
|
|
206
207
|
NSString *petID = PetPhrasesCurrentPetID();
|
|
207
208
|
BOOL hasPet = petID.length > 0;
|
|
208
209
|
[self.scopeControl setLabel:hasPet ?
|
|
209
|
-
[NSString stringWithFormat
|
|
210
|
-
@"
|
|
210
|
+
[NSString stringWithFormat:L(@"This Pet · %@"), [self displayNameForPetID:petID]] :
|
|
211
|
+
L(@"This Pet") forSegment:1];
|
|
211
212
|
[self.scopeControl setEnabled:hasPet forSegment:1];
|
|
212
213
|
|
|
213
214
|
// 宠物变了(或没了)而这一页正停在专属范围上:跟着走,但别把用户没存的东西冲掉。
|
|
@@ -226,7 +227,7 @@ static void (^PetPhrasesSpeakHandler)(NSString *);
|
|
|
226
227
|
|
|
227
228
|
- (void)syncRevertButtonTitle {
|
|
228
229
|
// 专属词库没有"默认"这一说,它的默认状态就是空文件(全部回落到通用)。
|
|
229
|
-
self.revertButton.title = self.petScope ? @"
|
|
230
|
+
self.revertButton.title = self.petScope ? L(@"Clear Page…") : L(@"Restore Defaults…");
|
|
230
231
|
// 通用页不需要这个按钮:它本来就是从默认台词拷出来的,不存在空白无从下手的问题,
|
|
231
232
|
// 想拿回默认内容有"恢复默认台词…"。
|
|
232
233
|
self.fillButton.hidden = !self.petScope;
|
|
@@ -256,10 +257,10 @@ static void (^PetPhrasesSpeakHandler)(NSString *);
|
|
|
256
257
|
|
|
257
258
|
- (BOOL)confirmDiscardChanges {
|
|
258
259
|
NSAlert *alert = [NSAlert new];
|
|
259
|
-
alert.messageText = @"
|
|
260
|
-
alert.informativeText = @"
|
|
261
|
-
[alert addButtonWithTitle
|
|
262
|
-
[alert addButtonWithTitle
|
|
260
|
+
alert.messageText = L(@"This Page Isn't Saved");
|
|
261
|
+
alert.informativeText = L(@"Unsaved changes will be lost if you switch.");
|
|
262
|
+
[alert addButtonWithTitle:L(@"Discard Changes")];
|
|
263
|
+
[alert addButtonWithTitle:L(@"Stay")];
|
|
263
264
|
return [alert runModal] == NSAlertFirstButtonReturn;
|
|
264
265
|
}
|
|
265
266
|
|
|
@@ -278,8 +279,7 @@ static void (^PetPhrasesSpeakHandler)(NSString *);
|
|
|
278
279
|
error:nil][NSFileModificationDate];
|
|
279
280
|
if (self.petScope && text.length == 0) {
|
|
280
281
|
[self showStatus:[NSString stringWithFormat:
|
|
281
|
-
@"%@ ·
|
|
282
|
-
"只写想改的小节即可,或点右上角「填入默认模板」看看能写些什么。", path]
|
|
282
|
+
L(@"%@ · Still empty, so this pet uses the shared lines. Only write the sections you want to change, or click “Insert Template” at the top right to see what's possible."), path]
|
|
283
283
|
warning:NO];
|
|
284
284
|
return;
|
|
285
285
|
}
|
|
@@ -337,7 +337,7 @@ static void (^PetPhrasesSpeakHandler)(NSString *);
|
|
|
337
337
|
|
|
338
338
|
NSString *path = [self currentFilePath];
|
|
339
339
|
if (path.length == 0) {
|
|
340
|
-
[self showStatus
|
|
340
|
+
[self showStatus:L(@"No pet is selected, so pet-specific lines can't be saved.") warning:YES];
|
|
341
341
|
return NO;
|
|
342
342
|
}
|
|
343
343
|
NSError *error = nil;
|
|
@@ -347,8 +347,8 @@ static void (^PetPhrasesSpeakHandler)(NSString *);
|
|
|
347
347
|
[NSFileManager.defaultManager createDirectoryAtPath:path.stringByDeletingLastPathComponent
|
|
348
348
|
withIntermediateDirectories:YES attributes:nil error:nil];
|
|
349
349
|
if (![normalized writeToFile:path atomically:YES encoding:NSUTF8StringEncoding error:&error]) {
|
|
350
|
-
[self showStatus:[NSString stringWithFormat
|
|
351
|
-
error.localizedDescription ?: @"
|
|
350
|
+
[self showStatus:[NSString stringWithFormat:L(@"Save failed: %@"),
|
|
351
|
+
error.localizedDescription ?: L(@"unknown error")] warning:YES];
|
|
352
352
|
return NO;
|
|
353
353
|
}
|
|
354
354
|
self.loadedStamp = [NSFileManager.defaultManager attributesOfItemAtPath:path
|
|
@@ -357,11 +357,12 @@ static void (^PetPhrasesSpeakHandler)(NSString *);
|
|
|
357
357
|
|
|
358
358
|
if (issues.count > 0) {
|
|
359
359
|
[self presentIssues:issues blocking:NO restored:nil];
|
|
360
|
-
[self showStatus:[NSString stringWithFormat
|
|
360
|
+
[self showStatus:[NSString stringWithFormat:issues.count != 1
|
|
361
|
+
? L(@"Saved, with %lu notices") : L(@"Saved, with %lu notice"),
|
|
361
362
|
(unsigned long)issues.count] warning:YES];
|
|
362
363
|
return YES;
|
|
363
364
|
}
|
|
364
|
-
[self showStatus
|
|
365
|
+
[self showStatus:L(@"Saved. Takes effect now.") warning:NO];
|
|
365
366
|
return YES;
|
|
366
367
|
}
|
|
367
368
|
|
|
@@ -372,12 +373,11 @@ static void (^PetPhrasesSpeakHandler)(NSString *);
|
|
|
372
373
|
if (!current || !self.loadedStamp || [current isEqualToDate:self.loadedStamp]) return YES;
|
|
373
374
|
|
|
374
375
|
NSAlert *alert = [NSAlert new];
|
|
375
|
-
alert.messageText = @"
|
|
376
|
-
alert.informativeText = @"
|
|
377
|
-
|
|
378
|
-
[alert addButtonWithTitle
|
|
379
|
-
[alert addButtonWithTitle
|
|
380
|
-
[alert addButtonWithTitle:@"重新载入"];
|
|
376
|
+
alert.messageText = L(@"File Changed on Disk");
|
|
377
|
+
alert.informativeText = L(@"Another app changed the lines file after the editor opened it. Saving will overwrite those changes.");
|
|
378
|
+
[alert addButtonWithTitle:L(@"Overwrite")];
|
|
379
|
+
[alert addButtonWithTitle:L(@"Cancel")];
|
|
380
|
+
[alert addButtonWithTitle:L(@"Reload")];
|
|
381
381
|
NSModalResponse response = [alert runModal];
|
|
382
382
|
if (response == NSAlertSecondButtonReturn) return NO;
|
|
383
383
|
if (response == NSAlertThirdButtonReturn) {
|
|
@@ -394,41 +394,41 @@ static void (^PetPhrasesSpeakHandler)(NSString *);
|
|
|
394
394
|
if (restored.count > 0) {
|
|
395
395
|
NSMutableArray<NSString *> *names = [NSMutableArray array];
|
|
396
396
|
for (NSString *tag in restored) {
|
|
397
|
-
[names addObject:[NSString stringWithFormat
|
|
397
|
+
[names addObject:[NSString stringWithFormat:L(@"[%1$@] (%2$@)"), tag,
|
|
398
398
|
PetPhraseTagDescription(tag)]];
|
|
399
399
|
}
|
|
400
400
|
[lines addObject:[NSString stringWithFormat:
|
|
401
|
-
@"
|
|
401
|
+
L(@"Tags can't be deleted, so %@ was put back in place (⌘Z to undo)."),
|
|
402
402
|
[names componentsJoinedByString:@"、"]]];
|
|
403
|
-
if (blocking) [lines addObject
|
|
403
|
+
if (blocking) [lines addObject:L(@"Nothing was saved. Check the restored tags, then save again.")];
|
|
404
404
|
[lines addObject:@""];
|
|
405
405
|
}
|
|
406
406
|
for (PetPhraseIssue *issue in issues) {
|
|
407
|
-
NSString *prefix = issue.level == PetPhraseIssueLevelError ? @"
|
|
407
|
+
NSString *prefix = issue.level == PetPhraseIssueLevelError ? L(@"Must fix: ") : L(@"Note: ");
|
|
408
408
|
NSString *where = issue.line > 0 ?
|
|
409
|
-
[NSString stringWithFormat
|
|
409
|
+
[NSString stringWithFormat:L(@"Line %ld "), (long)issue.line] : @"";
|
|
410
410
|
[lines addObject:[NSString stringWithFormat:@"%@%@%@", prefix, where, issue.message]];
|
|
411
411
|
// 一屏放不下就没人看了,剩下的等改完这批再报。
|
|
412
412
|
if (lines.count >= 12) {
|
|
413
|
-
[lines addObject:[NSString stringWithFormat
|
|
413
|
+
[lines addObject:[NSString stringWithFormat:L(@"…and %lu more"),
|
|
414
414
|
(unsigned long)(issues.count - lines.count + 1)]];
|
|
415
415
|
break;
|
|
416
416
|
}
|
|
417
417
|
}
|
|
418
418
|
NSAlert *alert = [NSAlert new];
|
|
419
419
|
if (blocking) {
|
|
420
|
-
alert.messageText = @"
|
|
420
|
+
alert.messageText = L(@"Can't Save Yet");
|
|
421
421
|
} else {
|
|
422
|
-
alert.messageText = issues.count > 0 ? @"
|
|
422
|
+
alert.messageText = issues.count > 0 ? L(@"Saved, but Some Lines Won't Be Used") : L(@"Saved");
|
|
423
423
|
}
|
|
424
424
|
alert.informativeText = [lines componentsJoinedByString:@"\n"];
|
|
425
425
|
alert.alertStyle = blocking ? NSAlertStyleWarning : NSAlertStyleInformational;
|
|
426
|
-
[alert addButtonWithTitle
|
|
426
|
+
[alert addButtonWithTitle:L(@"OK")];
|
|
427
427
|
[alert runModal];
|
|
428
428
|
if (blocking) {
|
|
429
429
|
[self showStatus:restored.count > 0 ?
|
|
430
|
-
@"
|
|
431
|
-
@"
|
|
430
|
+
L(@"Tags restored, nothing saved yet. Check and save again.") :
|
|
431
|
+
L(@"Some problems must be fixed before saving.") warning:YES];
|
|
432
432
|
}
|
|
433
433
|
}
|
|
434
434
|
|
|
@@ -448,12 +448,12 @@ static void (^PetPhrasesSpeakHandler)(NSString *);
|
|
|
448
448
|
}
|
|
449
449
|
NSString *text = PetPhraseForTagInText(tag, draft, [self sampleSlots]);
|
|
450
450
|
if (text.length == 0) {
|
|
451
|
-
[self showStatus:[NSString stringWithFormat
|
|
451
|
+
[self showStatus:[NSString stringWithFormat:L(@"[%@] has no usable lines."), tag] warning:YES];
|
|
452
452
|
return;
|
|
453
453
|
}
|
|
454
454
|
if (PetPhrasesSpeakHandler) PetPhrasesSpeakHandler(text);
|
|
455
|
-
[self showStatus:[NSString stringWithFormat
|
|
456
|
-
fellBack ? @"
|
|
455
|
+
[self showStatus:[NSString stringWithFormat:L(@"Trying: %1$@%2$@"), text,
|
|
456
|
+
fellBack ? L(@" (from the shared lines)") : @""] warning:NO];
|
|
457
457
|
}
|
|
458
458
|
|
|
459
459
|
// 预览用的假数据。用真实数据的话,没在跑 agent 时 {toolName} 之类全是空的,
|
|
@@ -484,14 +484,14 @@ static void (^PetPhrasesSpeakHandler)(NSString *);
|
|
|
484
484
|
if (defaults.length == 0) return nil;
|
|
485
485
|
|
|
486
486
|
NSString *petName = self.scopePetID.length > 0 ?
|
|
487
|
-
[self displayNameForPetID:self.scopePetID] : @"
|
|
487
|
+
[self displayNameForPetID:self.scopePetID] : L(@"this pet");
|
|
488
488
|
NSMutableString *text = [NSMutableString stringWithFormat:
|
|
489
|
-
@"# ↓↓↓
|
|
489
|
+
L(@"# ↓↓↓ Lines just for %1$@. Everything below is commented out and inactive ↓↓↓\n"
|
|
490
490
|
"#\n"
|
|
491
|
-
"#
|
|
492
|
-
"#
|
|
493
|
-
"#
|
|
494
|
-
"\n", petName
|
|
491
|
+
"# To give %1$@ its own lines for a situation, uncomment that tag and write lines under it\n"
|
|
492
|
+
"# An uncommented tag with no lines keeps the pet quiet in that situation\n"
|
|
493
|
+
"# Tags left commented out fall back to the shared lines\n"
|
|
494
|
+
"\n"), petName];
|
|
495
495
|
|
|
496
496
|
for (NSString *line in [defaults componentsSeparatedByString:@"\n"]) {
|
|
497
497
|
// 已经是注释的行不再叠一层 #,双井号只是噪音。空行保持空行,
|
|
@@ -505,17 +505,16 @@ static void (^PetPhrasesSpeakHandler)(NSString *);
|
|
|
505
505
|
- (void)fillFromDefault:(id)sender {
|
|
506
506
|
NSString *text = [self commentedDefaultText];
|
|
507
507
|
if (text.length == 0) {
|
|
508
|
-
[self showStatus
|
|
508
|
+
[self showStatus:L(@"Default lines file not found.") warning:YES];
|
|
509
509
|
return;
|
|
510
510
|
}
|
|
511
511
|
// 空白页直接填,不打断——那正是这个按钮存在的理由。已经写了东西才问一句。
|
|
512
512
|
if ((self.textView.string ?: @"").length > 0) {
|
|
513
513
|
NSAlert *alert = [NSAlert new];
|
|
514
|
-
alert.messageText = @"
|
|
515
|
-
alert.informativeText = @"
|
|
516
|
-
|
|
517
|
-
[alert addButtonWithTitle
|
|
518
|
-
[alert addButtonWithTitle:@"取消"];
|
|
514
|
+
alert.messageText = L(@"Overwrite This Page?");
|
|
515
|
+
alert.informativeText = L(@"This page will be replaced with the full default lines (all commented out). Nothing is saved yet; ⌘Z undoes it.");
|
|
516
|
+
[alert addButtonWithTitle:L(@"Overwrite")];
|
|
517
|
+
[alert addButtonWithTitle:L(@"Cancel")];
|
|
519
518
|
if ([alert runModal] != NSAlertFirstButtonReturn) return;
|
|
520
519
|
}
|
|
521
520
|
// 走 shouldChangeTextInRange: 而不是直接设 string,这样这一步能被 ⌘Z 撤销。
|
|
@@ -523,8 +522,7 @@ static void (^PetPhrasesSpeakHandler)(NSString *);
|
|
|
523
522
|
if (![self.textView shouldChangeTextInRange:all replacementString:text]) return;
|
|
524
523
|
[self.textView.textStorage replaceCharactersInRange:all withString:text];
|
|
525
524
|
[self.textView didChangeText];
|
|
526
|
-
[self showStatus
|
|
527
|
-
"把想改的那一节行首的 # 去掉,它才归这只宠物管。" warning:NO];
|
|
525
|
+
[self showStatus:L(@"Default lines inserted, all commented out and inactive. Remove the # in front of a section to make it this pet's own.") warning:NO];
|
|
528
526
|
}
|
|
529
527
|
|
|
530
528
|
#pragma mark - 恢复默认 / 清空
|
|
@@ -533,12 +531,12 @@ static void (^PetPhrasesSpeakHandler)(NSString *);
|
|
|
533
531
|
NSAlert *alert = [NSAlert new];
|
|
534
532
|
// 专属词库的"默认状态"就是空白:清空 = 这只宠物全部回落到通用台词。
|
|
535
533
|
// 拿默认词库去填它是错的——那等于把 22 个小节全部标成"专属接管",再也不会回落。
|
|
536
|
-
alert.messageText = self.petScope ? @"
|
|
534
|
+
alert.messageText = self.petScope ? L(@"Clear This Pet's Lines?") : L(@"Restore Default Lines?");
|
|
537
535
|
alert.informativeText = self.petScope ?
|
|
538
|
-
@"
|
|
539
|
-
@"
|
|
540
|
-
[alert addButtonWithTitle:self.petScope ? @"
|
|
541
|
-
[alert addButtonWithTitle
|
|
536
|
+
L(@"After clearing, this pet goes back to the shared lines. Nothing is saved yet; ⌘Z undoes it.") :
|
|
537
|
+
L(@"The editor content will be replaced with the default lines. Nothing is saved yet; ⌘Z undoes it.");
|
|
538
|
+
[alert addButtonWithTitle:self.petScope ? L(@"Clear") : L(@"Restore")];
|
|
539
|
+
[alert addButtonWithTitle:L(@"Cancel")];
|
|
542
540
|
if ([alert runModal] != NSAlertFirstButtonReturn) return;
|
|
543
541
|
|
|
544
542
|
NSString *text = @"";
|
|
@@ -546,7 +544,7 @@ static void (^PetPhrasesSpeakHandler)(NSString *);
|
|
|
546
544
|
text = [NSString stringWithContentsOfFile:PetPhrasesDefaultFilePath()
|
|
547
545
|
encoding:NSUTF8StringEncoding error:nil];
|
|
548
546
|
if (text.length == 0) {
|
|
549
|
-
[self showStatus
|
|
547
|
+
[self showStatus:L(@"Default lines file not found.") warning:YES];
|
|
550
548
|
return;
|
|
551
549
|
}
|
|
552
550
|
}
|
|
@@ -555,8 +553,8 @@ static void (^PetPhrasesSpeakHandler)(NSString *);
|
|
|
555
553
|
if (![self.textView shouldChangeTextInRange:all replacementString:text]) return;
|
|
556
554
|
[self.textView.textStorage replaceCharactersInRange:all withString:text];
|
|
557
555
|
[self.textView didChangeText];
|
|
558
|
-
[self showStatus:self.petScope ? @"
|
|
559
|
-
@"
|
|
556
|
+
[self showStatus:self.petScope ? L(@"Cleared. Click Save to write it to the file.") :
|
|
557
|
+
L(@"Default lines inserted. Click Save to write them to the file.") warning:NO];
|
|
560
558
|
}
|
|
561
559
|
|
|
562
560
|
@end
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#import "CCPetsPreviews.h"
|
|
2
|
+
#import "CCPetsL10n.h"
|
|
2
3
|
#import "QuotaDashboardView.h"
|
|
3
4
|
#import "MenuToggleSwitch.h"
|
|
4
5
|
#import "CCPetsUsage.h"
|
|
@@ -123,12 +124,12 @@ int RenderAgentStatusCard(NSString *path) {
|
|
|
123
124
|
glass.layer.borderColor = [NSColor colorWithWhite:1 alpha:0.48].CGColor;
|
|
124
125
|
[root addSubview:glass];
|
|
125
126
|
|
|
126
|
-
NSTextField *title = [NSTextField labelWithString
|
|
127
|
+
NSTextField *title = [NSTextField labelWithString:L(@"Codex · Task completed")];
|
|
127
128
|
title.frame = NSMakeRect(20, 30, glassSize.width - 80, 18);
|
|
128
129
|
title.font = [NSFont systemFontOfSize:13 weight:NSFontWeightSemibold];
|
|
129
130
|
title.textColor = [NSColor colorWithWhite:0.10 alpha:0.96];
|
|
130
131
|
[glass addSubview:title];
|
|
131
|
-
NSTextField *detail = [NSTextField labelWithString
|
|
132
|
+
NSTextField *detail = [NSTextField labelWithString:L(@"The current task is done.")];
|
|
132
133
|
detail.frame = NSMakeRect(20, 12, glassSize.width - 80, 17);
|
|
133
134
|
detail.font = [NSFont systemFontOfSize:12 weight:NSFontWeightRegular];
|
|
134
135
|
detail.textColor = [NSColor colorWithWhite:0.34 alpha:0.88];
|
|
@@ -143,7 +144,7 @@ int RenderAgentStatusCard(NSString *path) {
|
|
|
143
144
|
NSColor *green = [NSColor colorWithRed:0.18 green:0.68 blue:0.35 alpha:1];
|
|
144
145
|
icon.layer.backgroundColor = [green colorWithAlphaComponent:0.28].CGColor;
|
|
145
146
|
NSImage *image = [NSImage imageWithSystemSymbolName:@"checkmark"
|
|
146
|
-
accessibilityDescription
|
|
147
|
+
accessibilityDescription:L(@"Task completed")];
|
|
147
148
|
icon.image = [image imageWithSymbolConfiguration:
|
|
148
149
|
[NSImageSymbolConfiguration configurationWithPointSize:15 weight:NSFontWeightBold]];
|
|
149
150
|
icon.contentTintColor = [green blendedColorWithFraction:0.18
|
|
@@ -173,8 +174,8 @@ int RenderMenuSwitches(NSString *path) {
|
|
|
173
174
|
view.wantsLayer = YES;
|
|
174
175
|
view.layer.backgroundColor = [NSColor colorWithWhite:0.86 alpha:1].CGColor;
|
|
175
176
|
NSArray<NSDictionary *> *rows = @[
|
|
176
|
-
@{@"title": @"
|
|
177
|
-
@{@"title": @"
|
|
177
|
+
@{@"title": L(@"Task done"), @"state": @YES, @"y": @40},
|
|
178
|
+
@{@"title": L(@"Task failed"), @"state": @NO, @"y": @10}
|
|
178
179
|
];
|
|
179
180
|
for (NSDictionary *row in rows) {
|
|
180
181
|
CGFloat y = [row[@"y"] doubleValue];
|
|
@@ -213,7 +214,7 @@ int RenderPetSheet(NSString *path, NSString *sheetPath, NSInteger rowCount) {
|
|
|
213
214
|
if (rowCount <= 0) rowCount = 9;
|
|
214
215
|
NSImage *sheet = LoadPetSpriteImage(sheetPath, NSMakeSize(140, 150), rowCount);
|
|
215
216
|
if (!sheet) {
|
|
216
|
-
fprintf(stderr, "
|
|
217
|
+
fprintf(stderr, "%s\n", [NSString stringWithFormat:L(@"Can't load the sprite: %@"), sheetPath].UTF8String);
|
|
217
218
|
return EXIT_FAILURE;
|
|
218
219
|
}
|
|
219
220
|
|
|
@@ -12,9 +12,12 @@ int RestartAfterPID(pid_t pid, NSString *appPath, BOOL managed);
|
|
|
12
12
|
// npm 安装日志里是否只是暂时性故障(值得自动重试一次),而不是真的装不上。
|
|
13
13
|
BOOL UpdateFailureIsTransient(NSString *log);
|
|
14
14
|
|
|
15
|
-
// 从 GitHub Release
|
|
16
|
-
//
|
|
15
|
+
// 从 GitHub Release 描述里摘出更新要点,给更新弹窗用。Release 是多语言的:
|
|
16
|
+
// 只读取标题完全匹配当前语言的段落(英文是「English」,其他语言见各自表里的
|
|
17
|
+
// "Release Notes Section");没有对应段落时返回空数组,绝不读取全文。只取列表项,
|
|
18
|
+
// 去掉 Markdown 标记,代码块整段跳过。
|
|
17
19
|
// 每条超过 maxLength 个字符截断加「…」;超过 limit 条时只返回前 limit 条并把 *truncated 置 YES。
|
|
18
20
|
// 没有列表项返回空数组——没写说明就不展示,不去猜正文。
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
// language 是 CCPetsSupportedLanguages() 里的某一种(见 CCPetsL10n.h)。
|
|
22
|
+
NSArray<NSString *> *ReleaseNoteHighlightsForLanguage(NSString *body, NSString *language,
|
|
23
|
+
NSUInteger limit, NSUInteger maxLength, BOOL *truncated);
|