[Update] Config Page: Advanced Settings Tab. Add modal and section that is switchable between CPU and CUDA version.

This commit is contained in:
Sakamoto Shiina
2024-12-20 01:28:44 +09:00
parent 0eec985a62
commit 1d615ab97d
12 changed files with 238 additions and 47 deletions

View File

@@ -15,6 +15,7 @@ import {
import OpenFolderSvg from "@images/open_folder.svg?react";
import HelpSvg from "@images/help.svg?react";
export const AdvancedSettings = () => {
return (
@@ -22,6 +23,7 @@ export const AdvancedSettings = () => {
<OscIpAddressContainer />
<OscPortContainer />
<OpenConfigFolderContainer />
<OpenSwitchComputeDeviceModalContainer />
</>
);
};
@@ -92,4 +94,23 @@ const OpenConfigFolderContainer = () => {
/>
</>
);
};
import { useStore_OpenedQuickSetting } from "@store";
const OpenSwitchComputeDeviceModalContainer = () => {
const { t } = useTranslation();
const { updateOpenedQuickSetting } = useStore_OpenedQuickSetting();
const onClickFunction = () => {
updateOpenedQuickSetting("switch_compute_device");
};
return (
<>
<ActionButtonContainer
label={t("config_page.advanced_settings.switch_compute_device.label")}
IconComponent={HelpSvg}
onclickFunction={onClickFunction}
/>
</>
);
};

View File

@@ -2,6 +2,7 @@ import styles from "./ModalController.module.scss";
import { useStore_OpenedQuickSetting } from "@store";
import { Vr, VrcMicMuteSyncContainer } from "@setting_box";
import { UpdateModal } from "./update_modal/UpdateModal";
import { SwitchComputeDeviceModal } from "./switch_compute_device_modal/SwitchComputeDeviceModal";
export const ModalController = () => {
const { currentOpenedQuickSetting, updateOpenedQuickSetting } = useStore_OpenedQuickSetting();
if (currentOpenedQuickSetting.data === "") return null;
@@ -25,6 +26,8 @@ const QuickSettingsController = () => {
return <VrcMicMuteSyncContainer />;
case "update_software":
return <UpdateModal />;
case "switch_compute_device":
return <SwitchComputeDeviceModal />;
default:
return null;
}

View File

@@ -0,0 +1,47 @@
import styles from "./SwitchComputeDeviceModal.module.scss";
import { useTranslation } from "react-i18next";
import { useStore_OpenedQuickSetting } from "@store";
import { useComputeMode, useUpdateSoftware } from "@logics_common";
import { useIsSoftwareUpdating } from "@logics_common";
export const SwitchComputeDeviceModal = () => {
const { t } = useTranslation();
const { updateOpenedQuickSetting } = useStore_OpenedQuickSetting();
const { updateSoftware, updateSoftware_CUDA } = useUpdateSoftware();
const { updateIsSoftwareUpdating } = useIsSoftwareUpdating();
const { currentComputeMode } = useComputeMode();
const is_cpu_version = currentComputeMode.data === "cpu";
const switch_compute_device_desc = is_cpu_version
? t("switch_compute_device_modal.switch_to_cuda_desc")
: t("switch_compute_device_modal.switch_to_cpu_desc");
const accept_button_label = is_cpu_version
? t("switch_compute_device_modal.switch_to_cuda_button") // to CUDA
: t("switch_compute_device_modal.switch_to_cpu_button"); // to CPU
const onClickUpdateSoftware = () => {
updateIsSoftwareUpdating(true);
if (is_cpu_version === true) {
updateSoftware_CUDA();
} else {
updateSoftware();
}
};
return (
<div className={styles.container}>
<p className={styles.label}>{switch_compute_device_desc}</p>
<div className={styles.button_wrapper}>
<button className={styles.deny_button} onClick={() => updateOpenedQuickSetting("")} >{t("switch_compute_device_modal.close_modal")}</button>
<button className={styles.accept_button} onClick={onClickUpdateSoftware}>
{accept_button_label}
<p className={styles.restart_desc}>{t("switch_compute_device_modal.restart_desc")}</p>
</button>
</div>
</div>
);
};

View File

@@ -0,0 +1,69 @@
.container {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
gap: 2.4rem;
}
.label {
font-size: 2rem;
max-width: 48rem;
text-align: center;
color: var(--dark_basic_text_color);
}
.button_wrapper {
display: flex;
width: 100%;
gap: 2rem;
max-width: 48rem;
justify-content: space-between;
}
.deny_button, .accept_button {
font-size: 1.6rem;
padding: 1rem;
min-width: 10rem;
flex: 1;
// max-width: 20rem;
text-align: center;
border-radius: 0.4rem;
white-space: nowrap;
// overflow: hidden;
// text-overflow: ellipsis;
color: var(--dark_basic_text_color);
}
.accept_button {
background-color: var(--primary_550_color);
position: relative;
&:hover {
background-color: var(--primary_450_color);
}
&:active {
background-color: var(--primary_600_color);
}
}
.deny_button {
background-color: var(--dark_750_color);
&:hover {
background-color: var(--dark_700_color);
}
&:active {
background-color: var(--dark_800_color);
}
}
.restart_desc {
position: absolute;
top: 100%;
left: 50%;
margin-top: 1rem;
transform: translate(-50%);
color: var(--dark_basic_text_color);
font-size: 1.4rem;
width: max-content;
pointer-events: none;
}

View File

@@ -1,7 +1,7 @@
import styles from "./UpdateModal.module.scss";
import { useTranslation } from "react-i18next";
import { useStore_OpenedQuickSetting } from "@store";
import { useUpdateSoftware } from "@logics_common";
import { useComputeMode, useUpdateSoftware } from "@logics_common";
import { useIsSoftwareUpdating } from "@logics_common";
export const UpdateModal = () => {
@@ -9,18 +9,26 @@ export const UpdateModal = () => {
const { updateOpenedQuickSetting } = useStore_OpenedQuickSetting();
const { updateSoftware } = useUpdateSoftware();
const { updateIsSoftwareUpdating } = useIsSoftwareUpdating();
const { currentComputeMode } = useComputeMode();
const is_cpu_version = currentComputeMode.data === "cpu";
const onClickUpdateSoftware = () => {
updateIsSoftwareUpdating(true);
updateSoftware();
// Update to the same as now compute device
if (is_cpu_version === true) {
updateSoftware();
} else {
updateSoftware_CUDA();
}
};
return (
<div className={styles.container}>
<p className={styles.label}>{t("main_page.update_software_desc")}</p>
<p className={styles.label}>{t("update_modal.update_software_desc")}</p>
<div className={styles.button_wrapper}>
<button className={styles.deny_button} onClick={() => updateOpenedQuickSetting("")} >{t("main_page.deny_update_software")}</button>
<button className={styles.accept_button} onClick={onClickUpdateSoftware}>{t("main_page.accept_update_software")}</button>
<button className={styles.deny_button} onClick={() => updateOpenedQuickSetting("")} >{t("update_modal.deny_update_software")}</button>
<button className={styles.accept_button} onClick={onClickUpdateSoftware}>{t("update_modal.accept_update_software")}</button>
</div>
</div>
);

View File

@@ -16,7 +16,7 @@ export const UpdatingComponent = () => {
color: "var(--primary_300_color)",
}}/>
</div>
<p className={styles.label}>{t("main_page.confirmation_message.updating")}</p>
<p className={styles.label}>{t("main_page.updating")}</p>
</div>
);
};

View File

@@ -6,7 +6,12 @@ export const useUpdateSoftware = () => {
asyncStdoutToPython("/run/update_software");
};
const updateSoftware_CUDA = () => {
asyncStdoutToPython("/run/update_cuda_software");
};
return {
updateSoftware,
updateSoftware_CUDA,
};
};