diff --git a/rust/src/cmd.rs b/rust/src/cmd.rs index 0b55d89..df75594 100644 --- a/rust/src/cmd.rs +++ b/rust/src/cmd.rs @@ -49,7 +49,7 @@ pub async fn start_check(state: State<'_, Mutex>) -> Result Result<(), String> { +pub async fn startline(app: AppHandle, refresh: bool) -> Result<(), String> { log::debug!("invoke: startline"); let state = app.state::>(); @@ -61,7 +61,7 @@ pub async fn startline(app: AppHandle) -> Result<(), String> { } if let Some(p) = &mut appd.profile { log::debug!("{}", hash); - p.line_up(hash, app.clone()).await + p.line_up(hash, refresh, app.clone()).await .map_err(|e| format!("Lineup failed:\n{}", e))?; p.start(app.clone()).await .map_err(|e| format!("Startup failed:\n{}", e))?; diff --git a/rust/src/lib.rs b/rust/src/lib.rs index b30e0f8..dbc2d48 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -160,7 +160,7 @@ pub async fn run(_args: Vec) { apph.exit(1); } } - if let Err(e) = cmd::startline(apph.clone()).await { + if let Err(e) = cmd::startline(apph.clone(), false).await { log::error!("Unable to launch: {}", e); apph.exit(1); } diff --git a/rust/src/profiles/mod.rs b/rust/src/profiles/mod.rs index 55b275e..80f22f5 100644 --- a/rust/src/profiles/mod.rs +++ b/rust/src/profiles/mod.rs @@ -151,13 +151,13 @@ impl Profile { self.data.sgt = source.sgt; // } } - pub async fn line_up(&self, pkg_hash: String, _app: AppHandle) -> Result<()> { + pub async fn line_up(&self, pkg_hash: String, refresh: bool, _app: AppHandle) -> Result<()> { let info = match &self.data.display { None => None, Some(display) => display.line_up()? }; - let res = self.line_up_the_rest(pkg_hash).await; + let res = self.line_up_the_rest(pkg_hash, refresh).await; #[cfg(target_os = "windows")] if let Some(info) = info { @@ -171,7 +171,7 @@ impl Profile { res } - async fn line_up_the_rest(&self, pkg_hash: String) -> Result<()> { + async fn line_up_the_rest(&self, pkg_hash: String, refresh: bool) -> Result<()> { if !self.data_dir().exists() { tokio::fs::create_dir(self.data_dir()).await?; } @@ -180,7 +180,7 @@ impl Profile { util::clean_up_opts(self.data_dir().join("option"))?; - let hash_check = Self::hash_check(&hash_path, &pkg_hash).await?; + let hash_check = Self::hash_check(&hash_path, &pkg_hash).await? || refresh; prepare_packages(&self.meta, &self.data.mods, hash_check).await .map_err(|e| anyhow!("package configuration failed:\n{:?}", e))?; let mut ini = self.data.sgt.line_up(&self.meta, self.meta.game).await diff --git a/src/components/StartButton.vue b/src/components/StartButton.vue index 55ab56c..9ab03e9 100644 --- a/src/components/StartButton.vue +++ b/src/components/StartButton.vue @@ -2,6 +2,7 @@ import { Ref, computed, ref } from 'vue'; import Button from 'primevue/button'; import ConfirmDialog from 'primevue/confirmdialog'; +import ContextMenu from 'primevue/contextmenu'; import ScrollPanel from 'primevue/scrollpanel'; import { useConfirm } from 'primevue/useconfirm'; import { listen } from '@tauri-apps/api/event'; @@ -15,7 +16,7 @@ const confirmDialog = useConfirm(); type StartStatus = 'ready' | 'preparing' | 'running'; const startStatus: Ref = ref('ready'); -const startline = async (force: boolean) => { +const startline = async (force: boolean, refresh: boolean) => { startStatus.value = 'preparing'; if (!force) { @@ -38,7 +39,7 @@ const startline = async (force: boolean) => { message: message.join('\n'), header: 'Start check failed', accept: () => { - startline(true); + startline(true, refresh); }, }); startStatus.value = 'ready'; @@ -47,7 +48,7 @@ const startline = async (force: boolean) => { } try { await invoke('save_current_profile'); - await invoke('startline'); + await invoke('startline', { refresh }); } catch (_) { startStatus.value = 'ready'; } @@ -87,9 +88,29 @@ listen('launch-end', () => { const messageSplit = (message: any) => { return message.message?.split('\n'); }; + +const menuItems = [ + { + label: 'Refresh and start', + icon: 'pi pi-sync', + command: async () => await startline(false, true), + }, + { + label: 'Start unchecked', + icon: 'pi pi-exclamation-circle', + command: async () => await startline(true, false), + }, +]; +const menu = ref(); + +const showContextMenu = (event: Event) => { + event.preventDefault(); + menu.value.show(event); +};