Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add shared focus dependency parsing (增加国策树渲染时的共享国策依赖解析) #97

Merged
merged 3 commits into from
Sep 11, 2024

Conversation

IShiraiKurokoI
Copy link
Contributor

Controlled by sharedFocusIndex feature flag, default is true
sharedFocusIndex feature flag控制,默认为 true

image

@@ -30,6 +32,27 @@ export function getDependenciesFromText(text: string): Dependency[] {
match = regex.exec(text);
}

if (sharedFocusIndex){
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不建议直接改 getDependenciesFromText 这个函数,这个函数是所有preview共用的。
比较好的做法是去改 previewdef/focustree/loader.ts。
而且相比用正则匹配,你可以用 convertNodeToJson() 这个方法得到比较准确的值。这样可以避免有人在注释里面或者文本里面写 shared_focus = blabla。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

哦哦我给忘了,之前看数据的时候看到了focuses里有shared focus的键来着

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

把增量解析依赖文件的逻辑改到previewdef/focustree/loader.ts里了

@@ -17,7 +19,25 @@ export class FocusTreeLoader extends ContentLoader<FocusTreeLoaderResult> {
if (error || (content === undefined)) {
throw error;
}


const file = convertFocusFileNodeToJson(parseHoi4File(content, localize('infile', 'In file {0}:\n', this.file)),{});
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的constants需要和49行的传同一个实例

}
const filePath = findFileByFocusKey(sharedFocus);
if (filePath){
if(dependencies.findIndex((item) => item.path === filePath) === -1){
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if () { 这里需要加适当的空格

@IShiraiKurokoI
Copy link
Contributor Author

嗯嗯,以上的问题都改完了。

@herbix herbix merged commit a66a232 into herbix:master Sep 11, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants