Skip to content

Commit

Permalink
Merge pull request #1536 from ebkr/hide-mod-loader-disabling
Browse files Browse the repository at this point in the history
Prevent disabling/enabling mod loaders
  • Loading branch information
anttimaki authored Nov 13, 2024
2 parents 4c9a4ad + 291a925 commit 607a9d4
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ export default class App extends mixins(UtilityMixin) {
this.$watch('$q.dark.isActive', () => {
document.documentElement.classList.toggle('html--dark', this.$q.dark.isActive);
});
this.$store.commit('updateModLoaderPackageNames');
}
beforeCreate() {
Expand Down
13 changes: 10 additions & 3 deletions src/components/views/LocalModList/LocalModCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ export default class LocalModCard extends Vue {
missingDependencies: string[] = [];
disableChangePending = false;
get canBeDisabled(): boolean {
// Mod loader packages can't be disabled as it's hard to define
// what that should even do in all cases.
return !this.$store.getters['isModLoader'](this.mod.getName());
}
get donationLink() {
return this.tsMod ? this.tsMod.getDonationLink() : undefined;
}
Expand Down Expand Up @@ -246,7 +252,8 @@ function dependencyStringToModName(x: string) {
class='fas fa-exclamation-circle'
></i>
</span>
<span @click.prevent.stop="() => mod.isEnabled() ? disableMod() : enableMod(mod)"
<span v-if="canBeDisabled"
@click.prevent.stop="() => mod.isEnabled() ? disableMod() : enableMod(mod)"
class='card-header-icon'>
<div class="field">
<input :id="`switch-${mod.getName()}`"
Expand All @@ -264,10 +271,10 @@ function dependencyStringToModName(x: string) {
Uninstall
</a>

<a v-if="mod.isEnabled()" @click="disableMod()" class='card-footer-item'>
<a v-if="canBeDisabled && mod.isEnabled()" @click="disableMod()" class='card-footer-item'>
Disable
</a>
<a v-else @click="enableMod(mod)" class='card-footer-item' >
<a v-else-if="canBeDisabled && !mod.isEnabled()" @click="enableMod(mod)" class='card-footer-item' >
Enable
</a>

Expand Down
11 changes: 11 additions & 0 deletions src/r2mm/installing/profile_installers/ModLoaderVariantRecord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,14 @@ const VARIANTS = {
// Casting is done here to ensure the values are ModLoaderPackageMapping[]
export type GAME_NAME = keyof typeof VARIANTS;
export const MOD_LOADER_VARIANTS: {[key in GAME_NAME]: ModLoaderPackageMapping[]} = VARIANTS;

export function getModLoaderPackageNames() {
const names = MODLOADER_PACKAGES.map((mapping) => mapping.packageName);

// Hard code MelonLoader to avoid having to iterate over MODLOADER_PACKAGES
// for each game separately. Hopefully we'll get rid of this once ML v0.6.6
// is released, as it's supposed to fix a bug that forces some games to
// currently use the older versions.
names.push("LavaGang-MelonLoader");
return names;
}
13 changes: 13 additions & 0 deletions src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ import { FolderMigration } from '../migrations/FolderMigration';
import Game from '../model/game/Game';
import GameManager from '../model/game/GameManager';
import R2Error from '../model/errors/R2Error';
import { getModLoaderPackageNames } from '../r2mm/installing/profile_installers/ModLoaderVariantRecord';
import ManagerSettings from '../r2mm/manager/ManagerSettings';

Vue.use(Vuex);

export interface State {
activeGame: Game;
isMigrationChecked: boolean;
modLoaderPackageNames: string[];
_settings: ManagerSettings | null;
}

Expand All @@ -32,6 +34,7 @@ export const store = {
state: {
activeGame: GameManager.defaultGame,
isMigrationChecked: false,
modLoaderPackageNames: [],

// Access through getters to ensure the settings are loaded.
_settings: null,
Expand Down Expand Up @@ -87,9 +90,19 @@ export const store = {
},
setSettings(state: State, settings: ManagerSettings) {
state._settings = settings;
},
updateModLoaderPackageNames(state: State) {
// The list is static and doesn't change during runtime.
if (!state.modLoaderPackageNames.length) {
state.modLoaderPackageNames = getModLoaderPackageNames();
}
}
},
getters: {
isModLoader: (state: State) => (packageName: string): boolean => {
return state.modLoaderPackageNames.includes(packageName);
},

settings(state: State): ManagerSettings {
if (state._settings === null) {
throw new R2Error(
Expand Down

0 comments on commit 607a9d4

Please sign in to comment.