2022-03-03 03:19:26 +00:00
|
|
|
import { createPortal } from "react-dom";
|
|
|
|
import React, { useEffect, useState } from "react";
|
|
|
|
|
|
|
|
import { useAppSelector, useAppDispatch } from "../lib/hooks";
|
2022-03-03 04:23:06 +00:00
|
|
|
import { setPluginsTxtAndApplyLoadOrder } from "../slices/pluginsTxt";
|
2022-03-03 03:19:26 +00:00
|
|
|
import styles from "../styles/PluginTxtEditor.module.css";
|
2022-08-19 22:39:05 +00:00
|
|
|
import EscapeListener from "./EscapeListener";
|
2022-03-03 03:19:26 +00:00
|
|
|
|
|
|
|
export const excludedPlugins = [
|
|
|
|
"Skyrim.esm",
|
|
|
|
"Update.esm",
|
|
|
|
"Dawnguard.esm",
|
|
|
|
"HearthFires.esm",
|
|
|
|
"Dragonborn.esm",
|
|
|
|
];
|
|
|
|
|
|
|
|
type Props = {};
|
|
|
|
|
2022-03-19 19:45:40 +00:00
|
|
|
const PluginTxtEditor: React.FC<Props> = () => {
|
2022-03-03 03:19:26 +00:00
|
|
|
const [editPluginsTxt, setEditPluginsTxt] = useState<string | null>(null);
|
|
|
|
const [pluginsTxtShown, setPluginsTxtShown] = useState(false);
|
|
|
|
const dispatch = useAppDispatch();
|
|
|
|
const pluginsTxt = useAppSelector((state) => state.pluginsTxt);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
setPluginsTxtShown(false);
|
|
|
|
}, [dispatch, pluginsTxt]);
|
|
|
|
|
|
|
|
const onPluginsTxtButtonClick = async () => {
|
|
|
|
setEditPluginsTxt(pluginsTxt);
|
|
|
|
setPluginsTxtShown(true);
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
2022-08-19 22:39:05 +00:00
|
|
|
<EscapeListener onEscape={() => setPluginsTxtShown(false)} />
|
2022-03-16 02:33:44 +00:00
|
|
|
<p className={styles["top-spacing"]}>
|
2022-03-19 20:29:06 +00:00
|
|
|
<strong className={styles.step}>2. </strong>Paste or drag-and-drop your{" "}
|
2022-03-15 23:59:16 +00:00
|
|
|
<strong>
|
|
|
|
<code>plugins.txt</code>
|
|
|
|
</strong>{" "}
|
|
|
|
below to sort and enable the loaded plugins by your current load order.
|
2022-03-16 02:33:44 +00:00
|
|
|
<br />
|
|
|
|
<br />
|
2022-03-15 23:59:16 +00:00
|
|
|
The plugins.txt file is typically found at{" "}
|
|
|
|
<strong>
|
2022-03-16 02:33:44 +00:00
|
|
|
<code className={styles["break-word"]}>
|
|
|
|
C:\Users\username\AppData\Local\Skyrim Special Edition
|
|
|
|
</code>
|
2022-03-15 23:59:16 +00:00
|
|
|
</strong>
|
2022-03-19 21:49:33 +00:00
|
|
|
.
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
For Mod Organizer users, it is at{" "}
|
|
|
|
<strong>
|
|
|
|
<code className={styles["break-word"]}>
|
|
|
|
C:\Users\username\AppData\Local\ModOrganizer\Skyrim Special
|
|
|
|
Edition\profiles\profilename\plugins.txt
|
|
|
|
</code>
|
|
|
|
</strong>
|
2022-03-03 03:19:26 +00:00
|
|
|
</p>
|
2022-03-15 04:47:31 +00:00
|
|
|
<button onClick={onPluginsTxtButtonClick} className={styles.button}>
|
2022-03-03 03:19:26 +00:00
|
|
|
{!pluginsTxt ? "Paste" : "Edit"} Skyrim plugins.txt file
|
|
|
|
</button>
|
2022-03-10 05:46:59 +00:00
|
|
|
{typeof window !== "undefined" &&
|
2022-03-03 03:19:26 +00:00
|
|
|
createPortal(
|
|
|
|
<dialog open={pluginsTxtShown} className={styles.dialog}>
|
|
|
|
<h3>Paste plugins.txt</h3>
|
|
|
|
<p>
|
|
|
|
The plugins.txt file is typically found at{" "}
|
2022-03-15 23:59:16 +00:00
|
|
|
<strong>
|
2022-03-16 02:33:44 +00:00
|
|
|
<code className={styles["break-word"]}>
|
2022-03-15 23:59:16 +00:00
|
|
|
C:\Users\username\AppData\Local\Skyrim Special Edition
|
|
|
|
</code>
|
|
|
|
</strong>{" "}
|
|
|
|
(or{" "}
|
|
|
|
<strong>
|
2022-03-16 02:33:44 +00:00
|
|
|
<code className={styles["break-word"]}>
|
|
|
|
%LOCALAPPDATA%\Skyrim Special Edition
|
|
|
|
</code>
|
2022-03-15 23:59:16 +00:00
|
|
|
</strong>
|
2022-03-16 02:33:44 +00:00
|
|
|
).
|
|
|
|
<br />
|
|
|
|
<br />
|
2022-03-19 21:49:33 +00:00
|
|
|
For Mod Organizer users, it is at{" "}
|
|
|
|
<strong>
|
|
|
|
<code className={styles["break-word"]}>
|
|
|
|
C:\Users\username\AppData\Local\ModOrganizer\Skyrim Special
|
|
|
|
Edition\profiles\profilename\plugins.txt
|
|
|
|
</code>
|
|
|
|
</strong>
|
|
|
|
<br />
|
|
|
|
<br />
|
2022-03-16 02:33:44 +00:00
|
|
|
You can also drag-and-drop the file anywhere on the window to load
|
|
|
|
the file.
|
2022-03-03 03:19:26 +00:00
|
|
|
</p>
|
|
|
|
<textarea
|
|
|
|
value={editPluginsTxt ?? undefined}
|
|
|
|
onChange={(e) => setEditPluginsTxt(e.target.value)}
|
|
|
|
/>
|
|
|
|
<menu>
|
|
|
|
<button
|
|
|
|
onClick={() => {
|
|
|
|
setEditPluginsTxt(null);
|
|
|
|
setPluginsTxtShown(false);
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
Cancel
|
|
|
|
</button>
|
|
|
|
<button
|
|
|
|
onClick={() => {
|
2022-03-03 04:23:06 +00:00
|
|
|
dispatch(
|
|
|
|
setPluginsTxtAndApplyLoadOrder(editPluginsTxt ?? "")
|
|
|
|
);
|
2022-03-03 03:19:26 +00:00
|
|
|
setPluginsTxtShown(false);
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
Save
|
|
|
|
</button>
|
|
|
|
</menu>
|
|
|
|
</dialog>,
|
|
|
|
document.body
|
|
|
|
)}
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2022-03-19 19:45:40 +00:00
|
|
|
export default PluginTxtEditor;
|