Skip to content

Commit

Permalink
sort plugins by scene controllers first
Browse files Browse the repository at this point in the history
  • Loading branch information
alexpineda committed Nov 18, 2023
1 parent e3fe562 commit 4319e54
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 10 deletions.
17 changes: 12 additions & 5 deletions src/configuration-ui/plugins-configuration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ export const PluginsConfiguration = ({
setBanner: React.Dispatch<React.SetStateAction<string>>;
}) => {
const [ tabIndex, setTabIndex ] = useState( 0 );
const plugins = useStore( window.deps.usePluginsStore );
const { plugins } = useStore( window.deps.usePluginsStore );

const [ plugin, setSelectedPluginPackage ] = useState<PluginMetaData | undefined>(
plugins.plugins[0]
plugins[0]
);

const oldConfig = useRef( plugin?.config );
Expand Down Expand Up @@ -86,8 +86,15 @@ export const PluginsConfiguration = ({
display: "flex",
flexDirection: "column",
}}>
{plugins.plugins
.sort()
{plugins
.sort((a, b) => {
if (a.isSceneController && !b.isSceneController) {
return -1;
} else if (!a.isSceneController && b.isSceneController) {
return 1;
}
return (a.description ?? a.name).localeCompare(b.description ?? b.name);
})
.map( ( plugin ) => localPluginButton( plugin, !plugin.config?._enabled?.value ) )}
</div>
</Tab>
Expand All @@ -104,7 +111,7 @@ export const PluginsConfiguration = ({
{plugin?.description ?? plugin?.name} - {plugin?.version}
</h2>

{plugin && plugins.plugins.includes( plugin ) && (
{plugin && plugins.includes( plugin ) && (
<>
{!isDeprecated( plugin ) && (
<DetailSheet
Expand Down
1 change: 0 additions & 1 deletion src/core/unit-entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Unit } from "@core/unit";
import gameStore from "@stores/game-store";
import { IterableMap } from "@utils/data-structures/iteratible-map";

//TODO: Deprecate
// The primary purpose of this class is to provide a storage for damage effects, and serialization to plugins ui
// We can store damage effects in a map, and we can serialize the map to plugins ui via an ArrayBuffer of unitData
export class UnitEntities {
Expand Down
2 changes: 1 addition & 1 deletion src/render/vr/vr-button-react.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const VRButtonReact: React.FC<VRButtonProps> = ({ renderer }) => {
}
};

const buttonText = isSupported ? (currentSession ? "EXIT VR" : "ENTER VR") : 'VR NOT SUPPORTED';
const buttonText = isSupported ? (currentSession ? "Exit VR" : "Enter VR") : 'VR Not Supported';

return (
<InGameMenuButton onClick={handleClick} background={isSupported ? "var(--blue-5)" : "var(--gray-5)"}
Expand Down
6 changes: 3 additions & 3 deletions src/stores/plugin-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export class PluginsRepository {
let isSceneController = false;

const hostFile = plugin.files.includes("host.js")
? await fetch(`${pluginRootUrl}/dist/host.js`)
? await fetch(urlJoin(pluginRootUrl, "dist", "host.js"))
.then(async (r) => {
isSceneController = (await r.text()).includes("onEnterScene");
return true;
Expand All @@ -155,13 +155,13 @@ export class PluginsRepository {
: null;

const uiFile = plugin.files.includes("ui.js")
? await fetch(`${pluginRootUrl}/dist/ui.js`)
? await fetch(urlJoin(pluginRootUrl, "dist", "ui.js"))
.then(() => true)
.catch(() => false)
: "";

const readme = plugin.files.includes("readme.md")
? await fetch(`${pluginRootUrl}/readme.md`)
? await fetch(urlJoin(pluginRootUrl, "readme.md"))
.then((r) => r.text())
.catch(() => undefined)
: undefined;
Expand Down
4 changes: 4 additions & 0 deletions src/utils/data-structures/iterable-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ export class IterableSet<T> {
this.onChange( this.#copy );
}

get(index: number) {
return this.#copy[index];
}

[Symbol.iterator]() {
return this.#copy[Symbol.iterator]();
}
Expand Down

0 comments on commit 4319e54

Please sign in to comment.