Skip to content

Conversation

@esphas
Copy link

@esphas esphas commented Aug 24, 2025

as is said in #36, this PR provides basic mod support

  • no frontend change except for JsonView.svelte
  • will fetch all_mods.json only when url param m is specified (m=A,B,C means using mod A, B, C in this order)

check cdda-guide-mod.vercel.app for examples.

also check #202 before merging this one


EDIT

Given that additional content has been added to this branch, I will now summarize the main changes:

  • when url param m is present, fetch all_mods.json and load mod content in the specified order (App.svelte, data.ts)
  • handle monster blacklists and whitelists (data.ts)
  • added dependency svelecte to provide a dropdown for mod selection, with changes reflected on the page in real time (App.svelte)
  • when viewing raw JSON, distinguish between different mods (and base game content) (JsonView.svelte)
  • allow viewing main content added by each mod (App.svelte, ModCategory.svelte)
  • added 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 list

Unresolved issues:

Copy link
Owner

@nornagon nornagon left a 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";
Copy link
Owner

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
Comment on lines 335 to 339
const oldIndex = this._byType
.get(mappedType)!
.findIndex((x) => x.id === obj.id);
if (oldIndex !== -1) {
const oldObj = this._byType.get(mappedType)![oldIndex];
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
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[] {
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
getEnabledMods(): string[] {
get enabledMods(): string[] {

src/data.ts Outdated
}
}

availableMods(): string[] {
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
availableMods(): string[] {
get availableMods(): string[] {

src/data.ts Outdated
Comment on lines 412 to 413
modEnabled() {
return this._enabledMods.length > 0;
Copy link
Owner

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.

Comment on lines 19 to 22
const harvest = data.modEnabled()
? data.byIdMaybe("harvest", h.id)
: data.byId("harvest", h.id);
if (!harvest) return false;
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
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.

Comment on lines 14 to 22
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();
}
Copy link
Owner

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
Comment on lines 1114 to 1117
const group = this.modEnabled()
? this.byIdMaybe("item_group", entry.group)
: this.byId("item_group", entry.group);
if (!group) continue;
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
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
Comment on lines 1179 to 1182
const group = this.modEnabled()
? this.byIdMaybe("item_group", entry.group)
: this.byId("item_group", entry.group);
if (!group) continue;
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
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) {
Copy link
Owner

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!

@esphas
Copy link
Author

esphas commented Aug 26, 2025

some of the issues you mentioned were actually already addressed in #202, which I just closed since it became too large and complex.
I’ll spend some time breaking down those improvements and submitting them here in a more manageable way.

@esphas
Copy link
Author

esphas commented Aug 26, 2025

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.

Copy link

@j66493341 j66493341 left a comment

Choose a reason for hiding this comment

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

HS free fire

@nornagon
Copy link
Owner

nornagon commented Sep 6, 2025

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...)

  1. <section> never has another <section> inside it.
  2. Avoid dependencies if possible. At runtime we basically only depend on fuzzysort, gettext.js, lodash/throttle and transifex. I like to keep this list minimal.

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.

@esphas
Copy link
Author

esphas commented Sep 12, 2025

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...)

1. <section> never has another <section> inside it.

2. Avoid dependencies if possible. At runtime we basically only depend on fuzzysort, gettext.js, lodash/throttle and transifex. I like to keep this list minimal.

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.
I'm pretty swamped recently, so I won't be able to dive into the branch right away, but I'll check it out as soon as things calm down on my end.

@esphas
Copy link
Author

esphas commented Sep 17, 2025

@nornagon I just pulled your latest changes from the mod-tweaks branch - looks clean and clear to me. I've merged it into this branch and made a few cleanups:

  • removed svelecte dependency and related styles
  • removed the redundant "Mods" link (since we now have it in the footer)
  • add a "No mods enabled" hint text.

nothing more from my side for now.

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.

3 participants