import React, { useContext, useRef, useState, useEffect } from "react"; import Cookies from "js-cookie"; import { WorkerPoolContext } from "../lib/WorkerPool"; import { useAppSelector } from "../lib/hooks"; import { isPlugin, parsePluginFiles } from "../lib/plugins"; import styles from "../styles/DataDirPicker.module.css"; import { createPortal } from "react-dom"; type Props = {}; const DataDirPicker: React.FC = () => { const workerPool = useContext(WorkerPoolContext); const inputRef = useRef(null); const plugins = useAppSelector((state) => state.plugins.parsedPlugins); const pluginsPending = useAppSelector((state) => state.plugins.pending); const [loading, setLoading] = useState(false); const [uploadNoticeShown, setUploadNoticeShown] = useState(false); const [ignoreUploadNoticeChecked, setIgnoreUploadNoticeChecked] = useState(false); useEffect(() => { if (pluginsPending === 0 && loading) { setLoading(false); } else if (pluginsPending > 0 && !loading) { setLoading(true); } }, [pluginsPending, loading, setLoading]); // It would be nice to open the directory with window.showDirectoryPicker() in supported browsers, // but it does not allow selecting directories under C:\\Program Files and it does not throw any error // that I can catch here when a user tries to select it, so it's basically useless. So instead, I have // to use this non-standard webkitdirectory input attribute that loads all files in a directory instead // of just selecting the directory itself. Yay. const onDataDirButtonClick = async (event: { target: { files: FileList | null }; }) => { if (!workerPool || workerPool.availableWorkers.length === 0) { return alert("Workers not loaded yet"); } const files = event.target.files ?? []; const plugins = []; for (let i = 0; i < files.length; i++) { const file = files[i]; if (isPlugin(file)) { plugins.push(file); } } parsePluginFiles(plugins, workerPool); }; return ( <>

1. Select or drag-and-drop your Skyrim{" "} Data {" "} folder below to load the plugins and see all of the cell edits and conflicts for your current mod load order.

The Data folder can be found in the installation directory of the game.

For Mod Organizer users, select the mod directory located at{" "} C:\Users\username\AppData\Local\ModOrganizer\Skyrim Special Edition\mods .

{typeof window !== "undefined" && createPortal(

NOTE: the following dialog will ask you to upload all the files in your Data folder.  NOTHING WILL BE UPLOADED ANYWHERE. The plugin files will only be transferred to your browser and processed on your device.

Drag and drop the Data folder onto the web page to avoid the upload dialog entirely.

, document.body )} {/* input webkitdirectory is buggy, so keep it hidden and control it through a normal button */} ); }; export default DataDirPicker;