-
Notifications
You must be signed in to change notification settings - Fork 384
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
raidboss: refactor trigger loading #5047
Conversation
4552be1
to
eec49c3
Compare
// | ||
// JavaScript dictionaries are *almost* ordered automatically as we would want, | ||
// but want to handle missing ids and integer ids (you shouldn't, but just in case). | ||
class OrderedTriggerList { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was wrong with OrderedTriggerList?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing, just it mix-up the localization step and override step, and now they are separated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I don't really understand. You could replace ProcessedTrigger
with LocalizedTrigger
and this code would still work. Mostly I just know this existing code is working, and so I'd rather not replace it with something new, unless there's a reason to rewrite it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In particular, I think it's a little confusing from a user output error to have the override console messages come in the opposite order that they are overridden. If you have A B C triggers in order, this will print out C overrides B, and B overrides A, but in reality the load order is A B C.
Co-authored-by: Adrienne Walker <[email protected]>
Co-authored-by: Adrienne Walker <[email protected]>
Should we add legacy field like There is a deprecated |
// | ||
// JavaScript dictionaries are *almost* ordered automatically as we would want, | ||
// but want to handle missing ids and integer ids (you shouldn't, but just in case). | ||
class OrderedTriggerList { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I don't really understand. You could replace ProcessedTrigger
with LocalizedTrigger
and this code would still work. Mostly I just know this existing code is working, and so I'd rather not replace it with something new, unless there's a reason to rewrite it.
ui/raidboss/raidboss_config.ts
Outdated
@@ -1453,20 +1464,23 @@ const userFileHandler: UserFileCallback = ( | |||
if (!baseOptions.Triggers) | |||
return; | |||
|
|||
baseOptions.Triggers ??= []; | |||
baseOptions.LoadedTriggers ??= []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think LoadedTriggers
is an implementation detail and it doesn't make sense for it to be part of Options
. It's not something set by a user or the config.
If filename
is part of LooseTriggerSet
, then Triggers
can just be updated in place as it used to be, right? That's what I was trying to suggest before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm trying not to modified object in place 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, I think "don't modify things in place" is a good approach, but usually that means there needs to be a clear data pipeline or data should be in temporary scoped variables. I think passing things through Options
that shouldn't live in Options
is strictly worse. If anything, you're also now modifying Options
in place, which seems like the same issue.
(Also, this is already being modified in place on line 1336.)
Since there's already a lot going on here, what do you think about an approach of: (1) in this PR, keep modifying things in place / keep Options
as-is without new members (2) follow up with a different PR to change how triggers are loaded here and maybe return different things from this function, make it better?
ui/raidboss/raidboss_config.ts
Outdated
return [set.timeline, files[timelineFile]]; | ||
}; | ||
|
||
const flattenTimelinePlace = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this function delete set.timelineFile
then if you've removed it from the other function, since it's overriding the timeline?
ui/raidboss/popup-text.ts
Outdated
timelineTriggers?: LooseTimelineTrigger[]; | ||
triggers?: LooseTrigger[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
timelineTriggers?: LooseTimelineTrigger[]; | |
triggers?: LooseTrigger[]; |
Aren't these already defined in LooseTriggerSet
? I'm not sure I understand why they need to be re-listed here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LooseTriggerSet
now is triggers?: (LooseTrigger & LegacyTrigger)[];
and
export type LegacyTrigger = {
regexEn?: RegExp;
regexDe?: RegExp;
regexFr?: RegExp;
regexCn?: RegExp;
regexJa?: RegExp;
regexKo?: RegExp;
// @deprecated
netRegexEn?: RegExp;
netRegexFr?: RegExp;
netRegexDe?: RegExp;
netRegexCn?: RegExp;
netRegexJa?: RegExp;
netRegexKo?: RegExp;
};
Sure, sounds good! |
/** | ||
* @deprecated remove this after we don't support `netRegexCn` style triggers | ||
*/ | ||
export type LegacyLangSuffix = 'En' | 'De' | 'Fr' | 'Ja' | 'Cn' | 'Ko'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where does this get used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
regex${lang as LegacyLangSuffix}
netRegex${lang as LegacyLangSuffix}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I don't see what you're referring to. Which file is that in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's used to get legacy regexDe
/netRegexDe
property in popup-text.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$ git grep LegacyLangSuffix
resources/languages.ts:export type LegacyLangSuffix = 'En' | 'De' | 'Fr' | 'Ja' | 'Cn
' | 'Ko';
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the confusion, I just don't see what you mean. Did you mean to add these changes and they didn't save/commit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's strange, I remembered I used it in popup-test.ts
, maybe I lost it by mistake.
/** | ||
* @deprecated | ||
*/ | ||
export type LegacyTrigger = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this could be combined into LooseTrigger
. LooseTrigger
is the "user trigger, that could be missing fields, and could have old deprecated fields in it" type. It's the same reason that LooseTriggerSet
has zoneRegex
in it.
// | ||
// JavaScript dictionaries are *almost* ordered automatically as we would want, | ||
// but want to handle missing ids and integer ids (you shouldn't, but just in case). | ||
class OrderedTriggerList { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In particular, I think it's a little confusing from a user output error to have the override console messages come in the opposite order that they are overridden. If you have A B C triggers in order, this will print out C overrides B, and B overrides A, but in reality the load order is A B C.
Co-authored-by: Adrienne Walker <[email protected]>
this contains the change of #5045 and #5038, please review and merge them first
This PR seprated triggers loading into 3 seprated steps, loading, localizing and overriding for better maintenance