Skip to content

Commit

Permalink
feat: added support for args
Browse files Browse the repository at this point in the history
  • Loading branch information
cecilia-sanare committed Mar 20, 2024
1 parent 6479cea commit 7ad3760
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/pages/apps/AppPage.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { type FC } from 'react';
import { useMemo, type FC } from 'react';
import type { LoaderFunctionArgs } from 'react-router-dom';
import { useLoaderData } from '@rain-cafe/react-utils/react-router';
import { AppImage } from '../../components/AppImage';
import { Label } from '../../components/Label';
import { Pill, appSettingStatustoVariant } from '../../components/Pill';
import { Card } from '../../components/Card';
import { Code } from '../../components/Code';
import { getApp, getAppSettingStatus } from '@/service/protontweaks';
import { getApp, getAppSettingStatus, toLaunchOptions } from '@/service/protontweaks';
import type { App } from '@/types';

export async function loader({ params }: LoaderFunctionArgs) {
Expand All @@ -18,6 +18,7 @@ export async function loader({ params }: LoaderFunctionArgs) {
export const Component: FC = () => {
const app = useLoaderData<typeof loader>();
const environmentVariables = Object.entries(app.tweaks.env);
const launchOptions = useMemo(() => toLaunchOptions(app), [app]);

return (
<>
Expand All @@ -33,10 +34,7 @@ export const Component: FC = () => {
protontricks {app.id} {app.tweaks.tricks.join(' ')}
</Code>
<Label label="Launch Options" />
<Code>
{environmentVariables.map(([key, value]) => `${key}=${value} `).join()}
%command%
</Code>
<Code>{launchOptions}</Code>
</Card>
<Card>
<Label label="Tricks">
Expand Down
14 changes: 14 additions & 0 deletions src/service/protontweaks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,17 @@ export function getAppSettingStatus(app: App, key: keyof App['tweaks']['settings

return value ? AppSettingStatus.SUPPORTED : AppSettingStatus.UNSUPPORTED;
}

export function toLaunchOptions(app: App) {
const environmentVariables = Object.entries(app.tweaks.env);

const launchOptions = [];

launchOptions.push(...environmentVariables.map(([key, value]) => `${key}=${value}`));
launchOptions.push('%command%');
launchOptions.push(...app.tweaks.args);

console.log(launchOptions);

return launchOptions.join(' ');
}
1 change: 1 addition & 0 deletions src/types/apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export type App = {
tweaks: {
tricks: string[];
env: Record<string, string>;
args: string[];
settings: {
gamemode?: boolean;
mangohud?: boolean;
Expand Down

0 comments on commit 7ad3760

Please sign in to comment.