forked from akanyan/STARTLINER
feat: refresh+start button
This commit is contained in:
@ -49,7 +49,7 @@ pub async fn start_check(state: State<'_, Mutex<AppData>>) -> Result<Vec<StartCh
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn startline(app: AppHandle) -> Result<(), String> {
|
||||
pub async fn startline(app: AppHandle, refresh: bool) -> Result<(), String> {
|
||||
log::debug!("invoke: startline");
|
||||
|
||||
let state = app.state::<Mutex<AppData>>();
|
||||
@ -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))?;
|
||||
|
@ -160,7 +160,7 @@ pub async fn run(_args: Vec<String>) {
|
||||
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);
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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<StartStatus> = 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);
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ContextMenu ref="menu" :model="menuItems" />
|
||||
<ConfirmDialog>
|
||||
<template #container="{ message, acceptCallback, rejectCallback }">
|
||||
<div
|
||||
@ -138,7 +159,8 @@ const messageSplit = (message: any) => {
|
||||
aria-label="start"
|
||||
size="small"
|
||||
class="m-2.5"
|
||||
@click="startline(false)"
|
||||
@click="startline(false, false)"
|
||||
@contextmenu="showContextMenu"
|
||||
/>
|
||||
<Button
|
||||
v-else-if="startStatus === 'preparing'"
|
||||
|
Reference in New Issue
Block a user