feat: Small changes for showcase video

This commit is contained in:
LynithDev 2024-07-24 11:11:56 +02:00
parent a5ff33a912
commit 56df69f911
8 changed files with 36 additions and 52 deletions

View file

@ -1,3 +1,4 @@
/dist-isolation
/coverage
/src/bindings.ts
/dist

View file

@ -1,5 +0,0 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore
# This is done so that Tauri never complains that '../dist does not exist'

View file

@ -105,6 +105,14 @@ pub async fn run_cluster(uuid: Uuid) -> Result<(Uuid, u32), String> {
.id()
.unwrap_or(0);
// tokio::task::spawn(async move {
// let mut proc = c_lock.write().await;
// if let Err(err) = processor::wait_for(&mut proc).await {
// tracing::error!("Error waiting for process: {:?}", err);
// };
// });
// let mut proc = c_lock.write().await;
// processor::wait_for(&mut proc).await?;
Ok((p_uuid, p_pid))
@ -135,37 +143,6 @@ pub async fn kill_process(uuid: Uuid) -> Result<(), String> {
// }
// fn placeholder_cluster() -> Cluster {
// let path = ClusterPath("test".into());
// Cluster {
// uuid: Uuid::from_str("56d1cbcf-1961-4477-b263-80e3b1c7a9d1").unwrap(),
// stage: onelauncher::store::ClusterStage::Installed,
// path: path.0,
// meta: ClusterMeta {
// created_at: DateTime::from_timestamp_millis(1718297861712).unwrap(),
// modified_at: DateTime::from_timestamp_millis(1718297861712).unwrap(),
// group: vec![],
// icon: None,
// icon_url: None,
// loader: Loader::Vanilla,
// loader_version: None,
// mc_version: "1.8.9".into(),
// name: "Test Cluster".into(),
// overall_played: 58195,
// recently_played: 0,
// package_data: None,
// played_at: None,
// },
// memory: None,
// java: None,
// resolution: None,
// force_fullscreen: None,
// init_hooks: None,
// packages: HashMap::new(),
// update: None,
// }
// }
#[specta::specta]
#[tauri::command]
pub async fn get_cluster(uuid: Uuid) -> Result<Cluster, String> {

View file

@ -44,9 +44,7 @@ function AccountPopup(props: Popup.PopupProps) {
<div class="w-full h-px bg-gray-05 rounded-md" />
<AccountComponent username="Caledonian" uuid="f247be7c5b8241c69148793ded77e71f" />
<AccountComponent username="Caledonian" uuid="069a79f4-44e9-4726-a5be-fca90e38aaf5" />
<AccountComponent username="Caledonian" uuid="f247be7c5b8241c69148793ded77e71f" />
<AccountComponent username="Wyvest" uuid="a5331404-0e77-440e-8bef-24c071dac1ae" />
<div class="w-full h-px bg-gray-05 rounded-md" />

View file

@ -1,4 +1,4 @@
import { User03Icon } from '@untitled-theme/icons-solid';
import { Upload01Icon, User03Icon } from '@untitled-theme/icons-solid';
import { Index, type JSX, createEffect, createSignal, on } from 'solid-js';
import type { ClusterStepProps } from './ClusterCreationModal';
import ModrinthIcon from '~assets/logos/modrinth.svg?component-solid';
@ -19,7 +19,7 @@ const providers: Omit<ProviderCardProps, 'selected' | 'setSelected'>[] = [
},
{
name: 'Import',
icon: <User03Icon />,
icon: <Upload01Icon />,
},
];

View file

@ -11,11 +11,21 @@ export default function useCommand<R, E, Args extends unknown[]>(
...args: Args
): ResourceReturn<R> {
return createResource(async () => {
const value = await cmd(...args);
if (value.status === 'ok')
return value.data;
throw value.error;
console.log('aaaa', cmd);
const test = await tryResult(cmd, ...args);
console.log('bbbb');
return test;
});
}
export async function tryResult<R, E, Args extends unknown[]>(
cmd: (...args: Args) => Promise<Result<R, E>>,
...args: Args
): Promise<R> {
const value = await cmd(...args);
if (value.status === 'ok')
return value.data;
throw value.error;
}

View file

@ -105,14 +105,14 @@ function Banner() {
<div class="relative z-10 h-full px-8 py-6 text-fg-primary flex flex-col justify-between items-start">
<div class="flex flex-col gap-y-2">
<h1>Building worlds</h1>
<p>A description would go here if I was smart</p>
<p>DEV BUILD - NOT FINAL</p>
</div>
<div class="flex w-full flex-row justify-between items-end">
<div class="flex flex-row items-center gap-x-4">
<Button
buttonStyle="primary"
iconLeft={<PlayIcon />}
children="Launch 1.19.2"
children="Launch 1.20.4"
/>
<Button
buttonStyle="icon"

View file

@ -11,6 +11,7 @@ import { upperFirst } from '~utils/primitives';
import useClusterContext from '~ui/hooks/useCluster';
import Modal from '~ui/components/overlay/Modal';
import { bridge } from '~imports';
import { tryResult } from '~ui/hooks/useCommand';
function ClusterOverview() {
const cluster = useClusterContext();
@ -100,8 +101,10 @@ function DeleteModal(props: DeleteModalProps) {
}
function Banner(props: Cluster & { showDeletePrompt: () => void }) {
function launch() {
async function launch() {
const [uuid, pid] = await tryResult(bridge.commands.runCluster, props.uuid);
console.log(uuid, pid);
}
return (
@ -123,7 +126,7 @@ function Banner(props: Cluster & { showDeletePrompt: () => void }) {
<span class="text-xs text-fg-secondary">
Played for
{' '}
<b>{((props.meta.overall_played || 0n)).toString()}</b>
<b>{((props.meta.overall_played || 0 as unknown as bigint)).toString()}</b>
{' '}
hours
{/* TODO: Ask Pauline if this is measured in seconds or milliseconds */}
@ -147,7 +150,7 @@ function Banner(props: Cluster & { showDeletePrompt: () => void }) {
iconLeft={<PlayIcon />}
children="Launch"
class="!w-auto"
onClick={() => {}}
onClick={launch}
/>
</div>
</div>