[Refactor/TMP5] Refactor UI components and connect to backend APIs. (VR(Overlay))
This commit is contained in:
@@ -298,31 +298,31 @@ export const { atomInstance: Atom_IsOpenedMicWordFilterList, useHook: useStore_I
|
|||||||
|
|
||||||
|
|
||||||
// VR
|
// VR
|
||||||
export const { atomInstance: Atom_OverlaySmallLogSettings, useHook: useStore_OverlaySmallLogSettings } = createAtomWithHook({
|
// export const { atomInstance: Atom_OverlaySmallLogSettings, useHook: useStore_OverlaySmallLogSettings } = createAtomWithHook({
|
||||||
x_pos: 0.0,
|
// x_pos: 0.0,
|
||||||
y_pos: 0.0,
|
// y_pos: 0.0,
|
||||||
z_pos: 0.0,
|
// z_pos: 0.0,
|
||||||
x_rotation: 0.0,
|
// x_rotation: 0.0,
|
||||||
y_rotation: 0.0,
|
// y_rotation: 0.0,
|
||||||
z_rotation: 0.0,
|
// z_rotation: 0.0,
|
||||||
display_duration: 5,
|
// display_duration: 5,
|
||||||
fadeout_duration: 2,
|
// fadeout_duration: 2,
|
||||||
tracker: "HMD",
|
// tracker: "HMD",
|
||||||
}, "OverlaySmallLogSettings");
|
// }, "OverlaySmallLogSettings");
|
||||||
export const { atomInstance: Atom_IsEnabledOverlaySmallLog, useHook: useStore_IsEnabledOverlaySmallLog } = createAtomWithHook(false, "IsEnabledOverlaySmallLog");
|
// export const { atomInstance: Atom_IsEnabledOverlaySmallLog, useHook: useStore_IsEnabledOverlaySmallLog } = createAtomWithHook(false, "IsEnabledOverlaySmallLog");
|
||||||
export const { atomInstance: Atom_OverlayLargeLogSettings, useHook: useStore_OverlayLargeLogSettings } = createAtomWithHook({
|
// export const { atomInstance: Atom_OverlayLargeLogSettings, useHook: useStore_OverlayLargeLogSettings } = createAtomWithHook({
|
||||||
x_pos: 0.0,
|
// x_pos: 0.0,
|
||||||
y_pos: 0.0,
|
// y_pos: 0.0,
|
||||||
z_pos: 0.0,
|
// z_pos: 0.0,
|
||||||
x_rotation: 0.0,
|
// x_rotation: 0.0,
|
||||||
y_rotation: 0.0,
|
// y_rotation: 0.0,
|
||||||
z_rotation: 0.0,
|
// z_rotation: 0.0,
|
||||||
display_duration: 5,
|
// display_duration: 5,
|
||||||
fadeout_duration: 2,
|
// fadeout_duration: 2,
|
||||||
tracker: "HMD",
|
// tracker: "HMD",
|
||||||
}, "OverlayLargeLogSettings");
|
// }, "OverlayLargeLogSettings");
|
||||||
export const { atomInstance: Atom_IsEnabledOverlayLargeLog, useHook: useStore_IsEnabledOverlayLargeLog } = createAtomWithHook(false, "IsEnabledOverlayLargeLog");
|
// export const { atomInstance: Atom_IsEnabledOverlayLargeLog, useHook: useStore_IsEnabledOverlayLargeLog } = createAtomWithHook(false, "IsEnabledOverlayLargeLog");
|
||||||
export const { atomInstance: Atom_OverlayShowOnlyTranslatedMessages, useHook: useStore_OverlayShowOnlyTranslatedMessages } = createAtomWithHook(false, "OverlayShowOnlyTranslatedMessages");
|
// export const { atomInstance: Atom_OverlayShowOnlyTranslatedMessages, useHook: useStore_OverlayShowOnlyTranslatedMessages } = createAtomWithHook(false, "OverlayShowOnlyTranslatedMessages");
|
||||||
|
|
||||||
// Others
|
// Others
|
||||||
// export const { atomInstance: Atom_EnableAutoClearMessageInputBox, useHook: useStore_EnableAutoClearMessageInputBox } = createAtomWithHook(true, "EnableAutoClearMessageInputBox");
|
// export const { atomInstance: Atom_EnableAutoClearMessageInputBox, useHook: useStore_EnableAutoClearMessageInputBox } = createAtomWithHook(true, "EnableAutoClearMessageInputBox");
|
||||||
|
|||||||
@@ -3,9 +3,13 @@ import { createAtomWithHook } from "@store";
|
|||||||
import {
|
import {
|
||||||
ctranslate2_weight_type_status,
|
ctranslate2_weight_type_status,
|
||||||
whisper_weight_type_status,
|
whisper_weight_type_status,
|
||||||
|
ui_configs,
|
||||||
} from "@ui_configs";
|
} from "@ui_configs";
|
||||||
|
|
||||||
import { useSettingsLogics } from "./useSettingsLogics";
|
import {
|
||||||
|
useSettingsLogics,
|
||||||
|
useConfigFunctions,
|
||||||
|
} from "./useSettingsLogics";
|
||||||
|
|
||||||
|
|
||||||
export const SETTINGS_ARRAY = [
|
export const SETTINGS_ARRAY = [
|
||||||
@@ -378,6 +382,14 @@ export const SETTINGS_ARRAY = [
|
|||||||
logics_template_id: "toggle_enable_disable",
|
logics_template_id: "toggle_enable_disable",
|
||||||
base_endpoint_name: "overlay_small_log",
|
base_endpoint_name: "overlay_small_log",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Category: "Vr",
|
||||||
|
Base_Name: "OverlaySmallLogSettings",
|
||||||
|
default_value: ui_configs.overlay_small_log_default_settings,
|
||||||
|
ui_template_id: "object",
|
||||||
|
logics_template_id: "get_set",
|
||||||
|
base_endpoint_name: "overlay_small_log_settings",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Category: "Vr",
|
Category: "Vr",
|
||||||
Base_Name: "IsEnabledOverlayLargeLog",
|
Base_Name: "IsEnabledOverlayLargeLog",
|
||||||
@@ -386,18 +398,10 @@ export const SETTINGS_ARRAY = [
|
|||||||
logics_template_id: "toggle_enable_disable",
|
logics_template_id: "toggle_enable_disable",
|
||||||
base_endpoint_name: "overlay_large_log",
|
base_endpoint_name: "overlay_large_log",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
Category: "Vr",
|
|
||||||
Base_Name: "OverlaySmallLogSettings",
|
|
||||||
default_value: {},
|
|
||||||
ui_template_id: "object",
|
|
||||||
logics_template_id: "get_set",
|
|
||||||
base_endpoint_name: "overlay_small_log_settings",
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
Category: "Vr",
|
Category: "Vr",
|
||||||
Base_Name: "OverlayLargeLogSettings",
|
Base_Name: "OverlayLargeLogSettings",
|
||||||
default_value: {},
|
default_value: ui_configs.overlay_large_log_default_settings,
|
||||||
ui_template_id: "object",
|
ui_template_id: "object",
|
||||||
logics_template_id: "get_set",
|
logics_template_id: "get_set",
|
||||||
base_endpoint_name: "overlay_large_log_settings",
|
base_endpoint_name: "overlay_large_log_settings",
|
||||||
@@ -501,16 +505,6 @@ export const SETTINGS_ARRAY = [
|
|||||||
base_endpoint_name: "convert_message_to_hiragana",
|
base_endpoint_name: "convert_message_to_hiragana",
|
||||||
},
|
},
|
||||||
|
|
||||||
// Hotkeys
|
|
||||||
// {
|
|
||||||
// Category: "Hotkeys",
|
|
||||||
// Base_Name: "SendMessageHotkey",
|
|
||||||
// default_value: "",
|
|
||||||
// ui_template_id: "input",
|
|
||||||
// logics_template_id: "get_set",
|
|
||||||
// base_endpoint_name: "send_message_hotkey",
|
|
||||||
// },
|
|
||||||
|
|
||||||
// AdvancedSettings
|
// AdvancedSettings
|
||||||
{
|
{
|
||||||
Category: "AdvancedSettings",
|
Category: "AdvancedSettings",
|
||||||
@@ -561,7 +555,7 @@ for (const setting_data of SETTINGS_ARRAY) {
|
|||||||
createAtomWithHook(setting_data.default_value, setting_data.Base_Name);
|
createAtomWithHook(setting_data.default_value, setting_data.Base_Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
const buildCategoryApiFromSettings = (settings, settingsArray, Category) => {
|
const buildCategoryApiFromSettings = (settings, settingsArray, Category, extraFunctions = {}) => {
|
||||||
const api = {};
|
const api = {};
|
||||||
const filtered = settingsArray.filter((s) => s.Category === Category);
|
const filtered = settingsArray.filter((s) => s.Category === Category);
|
||||||
|
|
||||||
@@ -598,14 +592,14 @@ const buildCategoryApiFromSettings = (settings, settingsArray, Category) => {
|
|||||||
if (typeof settings[updateFromBackendKey] === "function") api[updateFromBackendKey] = settings[updateFromBackendKey];
|
if (typeof settings[updateFromBackendKey] === "function") api[updateFromBackendKey] = settings[updateFromBackendKey];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return { ...api, ...extraFunctions };
|
||||||
return api;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const createCategoryHook = (Category) => {
|
const createCategoryHook = (Category) => {
|
||||||
return () => {
|
return () => {
|
||||||
const { settings } = useSettingsLogics(SETTINGS_ARRAY, Category);
|
const { settings } = useSettingsLogics(SETTINGS_ARRAY, Category);
|
||||||
const autoApi = buildCategoryApiFromSettings(settings, SETTINGS_ARRAY, Category);
|
const extraFunctions = useConfigFunctions(Category);
|
||||||
|
const autoApi = buildCategoryApiFromSettings(settings, SETTINGS_ARRAY, Category, extraFunctions);
|
||||||
return { ...autoApi };
|
return { ...autoApi };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -185,3 +185,19 @@ export const useSettingsLogics = (settingsArray, Category) => {
|
|||||||
|
|
||||||
return { settings: result };
|
return { settings: result };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export const useConfigFunctions = (Category) => {
|
||||||
|
const { asyncStdoutToPython } = useStdoutToPython();
|
||||||
|
|
||||||
|
switch (Category) {
|
||||||
|
case "Vr":
|
||||||
|
return {
|
||||||
|
sendTextToOverlay: (text) => {
|
||||||
|
asyncStdoutToPython("/run/send_text_overlay", text);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
default:
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user