-
Couldn't load subscription status.
- Fork 37
[Mod Content] basic mod support #201
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
base: main
Are you sure you want to change the base?
Conversation
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.
looking good, just some minor comments
src/data.ts
Outdated
| this._nestedMapgensById.clear(); | ||
|
|
||
| for (const obj of this._raw) { | ||
| obj.__mod = "Dark Days Ahead"; |
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.
this should probably be the mod id rather than the mod name, and we can map id => name for display
src/data.ts
Outdated
| const oldIndex = this._byType | ||
| .get(mappedType)! | ||
| .findIndex((x) => x.id === obj.id); | ||
| if (oldIndex !== -1) { | ||
| const oldObj = this._byType.get(mappedType)![oldIndex]; |
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.
| const oldIndex = this._byType | |
| .get(mappedType)! | |
| .findIndex((x) => x.id === obj.id); | |
| if (oldIndex !== -1) { | |
| const oldObj = this._byType.get(mappedType)![oldIndex]; | |
| const oldObj = this._byTypeById | |
| .get(mappedType)!.get(obj.id); | |
| if (oldObj != null) { |
src/data.ts
Outdated
| return this._rawMods[modId]; | ||
| } | ||
|
|
||
| getEnabledMods(): string[] { |
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.
| getEnabledMods(): string[] { | |
| get enabledMods(): string[] { |
src/data.ts
Outdated
| } | ||
| } | ||
|
|
||
| availableMods(): string[] { |
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.
| availableMods(): string[] { | |
| get availableMods(): string[] { |
src/data.ts
Outdated
| modEnabled() { | ||
| return this._enabledMods.length > 0; |
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 is fine to be inlined at the call sites; no need for a dedicated helper function.
src/types/item/HarvestedFrom.svelte
Outdated
| const harvest = data.modEnabled() | ||
| ? data.byIdMaybe("harvest", h.id) | ||
| : data.byId("harvest", h.id); | ||
| if (!harvest) return false; |
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.
| const harvest = data.modEnabled() | |
| ? data.byIdMaybe("harvest", h.id) | |
| : data.byId("harvest", h.id); | |
| if (!harvest) return false; | |
| const harvest = data.byIdMaybe("harvest", h.id); | |
| if (!harvest) return false; |
i think it's ok not to throw an error here when this isn't found, even if there are no mods enabled.
src/JsonView.svelte
Outdated
| function allSources(o: any): any[] { | ||
| const sources: any[] = []; | ||
| sources.push(o.__self); | ||
| while (o.__prevSelf) { | ||
| sources.push(o.__prevSelf); | ||
| o = o.__prevSelf; | ||
| } | ||
| return sources.reverse(); | ||
| } |
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.
share code with the helper in data.ts?
src/data.ts
Outdated
| const group = this.modEnabled() | ||
| ? this.byIdMaybe("item_group", entry.group) | ||
| : this.byId("item_group", entry.group); | ||
| if (!group) continue; |
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.
| const group = this.modEnabled() | |
| ? this.byIdMaybe("item_group", entry.group) | |
| : this.byId("item_group", entry.group); | |
| if (!group) continue; | |
| const group = this.byIdMaybe("item_group", entry.group); | |
| if (!group) continue; |
src/data.ts
Outdated
| const group = this.modEnabled() | ||
| ? this.byIdMaybe("item_group", entry.group) | ||
| : this.byId("item_group", entry.group); | ||
| if (!group) continue; |
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.
| const group = this.modEnabled() | |
| ? this.byIdMaybe("item_group", entry.group) | |
| : this.byId("item_group", entry.group); | |
| if (!group) continue; | |
| const group = this.byIdMaybe("item_group", entry.group); | |
| if (!group) continue; |
| } | ||
|
|
||
| let parent: any = null; | ||
| if (obj.__prevSelf != null) { |
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.
just realised that this means we show the copy-from links in the UI even for non-mod items. that's a nice little upgrade!
|
some of the issues you mentioned were actually already addressed in #202, which I just closed since it became too large and complex. |
|
that's all for now. I'm done adding new features to this PR, and any future commits will just be for bug fixes or tidying up. |
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.
HS free fire
|
I've been working on top of this branch to tweak stuff a bit. I didn't like the Svelecte component, so I embarked on a rework of the mod selection UI. Take a look at the branch nornagon/mod-tweaks. I couldn't figure out how to make GitHub display a diff from the base to the fork, but you should be able to at least check out the branch locally... Not quite done yet but just so you know, here are some general principles I've been working by (but never wrote down...)
I'm also violating a 3rd principle, which is that the only things that are interactable are links—the checkboxes in the mod catalog aren't links—so I'll think about if I'm ok with that. |
thanks for the update and for writing down those principles. |
o mods enabled hint
|
@nornagon I just pulled your latest changes from the
nothing more from my side for now. |
as is said in #36, this PR provides basic mod support
all_mods.jsononly when url parammis specified (m=A,B,Cmeans using mod A, B, C in this order)check cdda-guide-mod.vercel.app for examples.
also check #202 before merging this oneEDIT
Given that additional content has been added to this branch, I will now summarize the main changes:
mis present, fetchall_mods.jsonand load mod content in the specified order (App.svelte,data.ts)data.ts)svelecteto provide a dropdown for mod selection, with changes reflected on the page in real time (App.svelte)JsonView.svelte)App.svelte,ModCategory.svelte)ModTag.svelte, which can be used to display the mod override chain (e.g.,A > B > C), though it is not currently in use to avoid an excessively long change listUnresolved issues: