Initial commit, mod action done, plugin WIP
Finally managed to get the wasm module loaded and executing using some webpack witchcraft. Still need to actually implement the plugin action.
This commit is contained in:
commit
5f8e00c300
130
.gitignore
vendored
Normal file
130
.gitignore
vendored
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
.pnpm-debug.log*
|
||||||
|
|
||||||
|
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||||
|
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||||
|
|
||||||
|
# Runtime data
|
||||||
|
pids
|
||||||
|
*.pid
|
||||||
|
*.seed
|
||||||
|
*.pid.lock
|
||||||
|
|
||||||
|
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||||
|
lib-cov
|
||||||
|
|
||||||
|
# Coverage directory used by tools like istanbul
|
||||||
|
coverage
|
||||||
|
*.lcov
|
||||||
|
|
||||||
|
# nyc test coverage
|
||||||
|
.nyc_output
|
||||||
|
|
||||||
|
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||||
|
.grunt
|
||||||
|
|
||||||
|
# Bower dependency directory (https://bower.io/)
|
||||||
|
bower_components
|
||||||
|
|
||||||
|
# node-waf configuration
|
||||||
|
.lock-wscript
|
||||||
|
|
||||||
|
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||||
|
build/Release
|
||||||
|
|
||||||
|
# Dependency directories
|
||||||
|
node_modules/
|
||||||
|
jspm_packages/
|
||||||
|
|
||||||
|
# Snowpack dependency directory (https://snowpack.dev/)
|
||||||
|
web_modules/
|
||||||
|
|
||||||
|
# TypeScript cache
|
||||||
|
*.tsbuildinfo
|
||||||
|
|
||||||
|
# Optional npm cache directory
|
||||||
|
.npm
|
||||||
|
|
||||||
|
# Optional eslint cache
|
||||||
|
.eslintcache
|
||||||
|
|
||||||
|
# Optional stylelint cache
|
||||||
|
.stylelintcache
|
||||||
|
|
||||||
|
# Microbundle cache
|
||||||
|
.rpt2_cache/
|
||||||
|
.rts2_cache_cjs/
|
||||||
|
.rts2_cache_es/
|
||||||
|
.rts2_cache_umd/
|
||||||
|
|
||||||
|
# Optional REPL history
|
||||||
|
.node_repl_history
|
||||||
|
|
||||||
|
# Output of 'npm pack'
|
||||||
|
*.tgz
|
||||||
|
|
||||||
|
# Yarn Integrity file
|
||||||
|
.yarn-integrity
|
||||||
|
|
||||||
|
# dotenv environment variable files
|
||||||
|
.env
|
||||||
|
.env.development.local
|
||||||
|
.env.test.local
|
||||||
|
.env.production.local
|
||||||
|
.env.local
|
||||||
|
|
||||||
|
# parcel-bundler cache (https://parceljs.org/)
|
||||||
|
.cache
|
||||||
|
.parcel-cache
|
||||||
|
|
||||||
|
# Next.js build output
|
||||||
|
.next
|
||||||
|
out
|
||||||
|
|
||||||
|
# Nuxt.js build / generate output
|
||||||
|
.nuxt
|
||||||
|
dist
|
||||||
|
|
||||||
|
# Gatsby files
|
||||||
|
.cache/
|
||||||
|
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||||
|
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||||
|
# public
|
||||||
|
|
||||||
|
# vuepress build output
|
||||||
|
.vuepress/dist
|
||||||
|
|
||||||
|
# vuepress v2.x temp and cache directory
|
||||||
|
.temp
|
||||||
|
.cache
|
||||||
|
|
||||||
|
# Docusaurus cache and generated files
|
||||||
|
.docusaurus
|
||||||
|
|
||||||
|
# Serverless directories
|
||||||
|
.serverless/
|
||||||
|
|
||||||
|
# FuseBox cache
|
||||||
|
.fusebox/
|
||||||
|
|
||||||
|
# DynamoDB Local files
|
||||||
|
.dynamodb/
|
||||||
|
|
||||||
|
# TernJS port file
|
||||||
|
.tern-port
|
||||||
|
|
||||||
|
# Stores VSCode versions used for testing VSCode extensions
|
||||||
|
.vscode-test
|
||||||
|
|
||||||
|
# yarn v2
|
||||||
|
.yarn/cache
|
||||||
|
.yarn/unplugged
|
||||||
|
.yarn/build-state.yml
|
||||||
|
.yarn/install-state.gz
|
||||||
|
.pnp.*
|
17
.vscode/tasks.json
vendored
Normal file
17
.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"type": "npm",
|
||||||
|
"script": "build",
|
||||||
|
"problemMatcher": [
|
||||||
|
"$tsc"
|
||||||
|
],
|
||||||
|
"group": {
|
||||||
|
"kind": "build",
|
||||||
|
"isDefault": true
|
||||||
|
},
|
||||||
|
"label": "npm: build"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
9
LICENSE
Normal file
9
LICENSE
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2022 Mike Watling
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
35
package.json
Normal file
35
package.json
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
{
|
||||||
|
"name": "modmapper-integration",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"description": "Allow mods and plugins to be opened with ModMapper",
|
||||||
|
"main": "./dist/index.js",
|
||||||
|
"scripts": {
|
||||||
|
"webpack": "node ./node_modules/webpack/bin/webpack --config webpack.config.js --display-error-details --progress --profile --color",
|
||||||
|
"build": "npm run webpack && extractInfo && copyfiles -f ./gameart.png ./dist/"
|
||||||
|
},
|
||||||
|
"author": "Critterman",
|
||||||
|
"license": "GPL 3.0",
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/node": "^12.12.35",
|
||||||
|
"@types/react": "^16.9.43",
|
||||||
|
"@types/react-bootstrap": "^0.32.20",
|
||||||
|
"@types/redux": "^3.6.0",
|
||||||
|
"@types/redux-thunk": "^2.1.0",
|
||||||
|
"bluebird": "^3.7.2",
|
||||||
|
"copyfiles": "^2.4.1",
|
||||||
|
"i18next": "^19.0.1",
|
||||||
|
"react": "^16.12.0",
|
||||||
|
"react-bootstrap": "^0.33.0",
|
||||||
|
"react-dom": "^16.12.0",
|
||||||
|
"skyrim-cell-dump-wasm": "0.1.0",
|
||||||
|
"ts-loader": "^6.0.4",
|
||||||
|
"typescript": "^3.5.2",
|
||||||
|
"vortex-api": "github:Nexus-Mods/vortex-api",
|
||||||
|
"webpack": "^4.35.0",
|
||||||
|
"webpack-cli": "^3.3.4",
|
||||||
|
"webpack-dynamic-public-path": "^1.0.8"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"url-loader": "^4.1.1"
|
||||||
|
}
|
||||||
|
}
|
69
src/index.ts
Normal file
69
src/index.ts
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
import { log, selectors, types, util } from "vortex-api";
|
||||||
|
import { IExtensionContext } from 'vortex-api/lib/types/api';
|
||||||
|
import { loadWasm } from "./wasmLoader";
|
||||||
|
|
||||||
|
const supportedGames: string[] = [ 'skyrimse', 'skyrimspecialedition', 'skyrimvr' ];
|
||||||
|
const modMapperBase: string = 'https://modmapper.com/';
|
||||||
|
|
||||||
|
// Added gameId for future use?
|
||||||
|
const modmapperModUrl = (gameId: string, modId: number): string => `${modMapperBase}?mod=${modId}`;
|
||||||
|
|
||||||
|
function pluginPath(pluginName : string, api : types.IExtensionApi): string {
|
||||||
|
const store = api.store
|
||||||
|
const activeGameId = selectors.activeGameId(store.getState());
|
||||||
|
|
||||||
|
const gamePath = util.getSafe(store.getState(), ['settings', 'gameMode', 'discovered', activeGameId, 'path'], undefined);
|
||||||
|
return `${gamePath}${pluginName}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
//This is the main function Vortex will run when detecting the game extension.
|
||||||
|
function main(context: IExtensionContext) {
|
||||||
|
|
||||||
|
// Add button to the mods table.
|
||||||
|
context.registerAction('mods-action-icons', 999, 'highlight-map', {}, 'See on Modmapper',
|
||||||
|
(instanceIds: string[]) => {
|
||||||
|
// Open the modmapper page
|
||||||
|
const state = context.api.getState();
|
||||||
|
const gameId = selectors.activeGameId(state);
|
||||||
|
const mod = util.getSafe(state, ['persistent', 'mods', gameId, instanceIds[0]], undefined);
|
||||||
|
// could not find the mod in the state.
|
||||||
|
if (!mod) return;
|
||||||
|
// Is this mod from gather the info about the mod.
|
||||||
|
const game: string = mod.attributes?.downloadGame;
|
||||||
|
const modId: number = mod.attributes?.modId;
|
||||||
|
loadWasm(({ hash_plugin }) => alert(hash_plugin(new Uint8Array([1, 2, 3]))));
|
||||||
|
return util.opn(modmapperModUrl(game, modId)).catch((err) => log('error', 'Could not open web page', err));
|
||||||
|
},
|
||||||
|
(instanceIds: string[]): boolean => {
|
||||||
|
// Should we show the option?
|
||||||
|
const state = context.api.getState();
|
||||||
|
const gameId: string = selectors.activeGameId(state);
|
||||||
|
const mod: (types.IMod | undefined) = util.getSafe(state, ['persistent', 'mods', gameId, instanceIds[0]], undefined);
|
||||||
|
// Make sure this mod is from Nexus Mods
|
||||||
|
const nexusMods: boolean = mod?.attributes?.source === 'nexus';
|
||||||
|
// Make sure this is from a Nexus Mods section we support
|
||||||
|
const gameIsSupported: boolean = supportedGames.includes(mod?.attributes?.downloadGame);
|
||||||
|
// Make sure this mod has a mod ID
|
||||||
|
const hasModId: boolean = !!mod?.attributes?.modId;
|
||||||
|
|
||||||
|
return (nexusMods && gameIsSupported && hasModId);
|
||||||
|
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// Add button to the plugins table.
|
||||||
|
context.registerAction('gamebryo-plugins-action-icons', 100, 'highlight-map', {}, 'See on Modmapper',
|
||||||
|
(instanceIds: string[]) => {
|
||||||
|
alert(pluginPath(instanceIds[0], context.api));
|
||||||
|
},
|
||||||
|
(instanceIds: string[]) => {
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
default: main,
|
||||||
|
};
|
3
src/wasmLoader.js
Normal file
3
src/wasmLoader.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export function loadWasm(closure) {
|
||||||
|
import("skyrim-cell-dump-wasm").then(closure);
|
||||||
|
}
|
23
tsconfig.json
Normal file
23
tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "es2019",
|
||||||
|
"module": "commonjs",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"noImplicitAny": false,
|
||||||
|
"removeComments": true,
|
||||||
|
"preserveConstEnums": true,
|
||||||
|
"rootDir": "src",
|
||||||
|
"outDir": "./out",
|
||||||
|
"jsx": "react",
|
||||||
|
"sourceMap": false,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"skipLibCheck": true
|
||||||
|
},
|
||||||
|
"exclude": [
|
||||||
|
"node_modules",
|
||||||
|
"**/*.wasm"
|
||||||
|
],
|
||||||
|
"include": [
|
||||||
|
"src/index.ts"
|
||||||
|
]
|
||||||
|
}
|
16
webpack.config.js
Normal file
16
webpack.config.js
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
let webpack = require('vortex-api/bin/webpack').default;
|
||||||
|
const WebpackDynamicPublicPathPlugin = require("webpack-dynamic-public-path");
|
||||||
|
|
||||||
|
const config = webpack('modmapper-integration', __dirname, 4);
|
||||||
|
|
||||||
|
config.resolve.extensions.push(".wasm");
|
||||||
|
config.entry = { app: "./src/index.ts" };
|
||||||
|
|
||||||
|
config.output.publicPath = "publicPathPlaceholder";
|
||||||
|
// hack to get webpack to load chunks and wasm from the vortex extension directory
|
||||||
|
config.plugins.push(new WebpackDynamicPublicPathPlugin({
|
||||||
|
externalPublicPath: `"file:///" + __dirname + "/"`,
|
||||||
|
chunkNames: ["app"],
|
||||||
|
}));
|
||||||
|
|
||||||
|
module.exports = config;
|
Loading…
Reference in New Issue
Block a user