Skip to content

Commit

Permalink
input processor
Browse files Browse the repository at this point in the history
  • Loading branch information
TuTiDore committed Dec 19, 2023
1 parent 95a9ed0 commit 2f1b13b
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 6 deletions.
15 changes: 14 additions & 1 deletion src/data/stringArrayTypes.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { FeProcessingMode } from "src-tauri/bindings/FeProcessingMode";
import { PenetrationSystemType } from "src-tauri/bindings/PenetrationSystemType";
import { FeVCToyAnatomy } from "../../src-tauri/bindings/FeVCToyAnatomy";

/*
Expand Down Expand Up @@ -40,8 +42,19 @@ export const ToyAnatomyArray = [
"Vulva",
"Wrist",
] as const;

// eslint-disable-next-line @typescript-eslint/no-unused-vars
type AnatomyIsSame = StaticAssert<
TypesAreEqual<FeVCToyAnatomy, (typeof ToyAnatomyArray)[number]>
>;

export const PenetrationSystems = ["NONE", "TPS", "SPS"] as const;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
type PenTypeIsSame = StaticAssert<
TypesAreEqual<PenetrationSystemType, (typeof PenetrationSystems)[number]>
>;

export const ProcessingModes = ["Raw", "Smooth", "Rate", "Constant"] as const;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
type ProcessingModeIsSame = StaticAssert<
TypesAreEqual<FeProcessingMode, (typeof ProcessingModes)[number]>
>;
49 changes: 44 additions & 5 deletions src/features/FeatureForm.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Button } from "@/components/ui/button";
import { ScrollArea } from "@/components/ui/scroll-area";
import { PenetrationSystems, ProcessingModes } from "@/data/stringArrayTypes";
import { Select } from "@/layout/Select";
import { Plus, X } from "lucide-react";
import { ChangeEvent, useEffect, useState } from "react";
Expand Down Expand Up @@ -34,9 +35,6 @@ export default function FeatureForm({
type SubmenuOptions = (typeof submenuOptions)[number];
const [subMenu, setSubMenu] = useState<SubmenuOptions>("Parameters");

const modeOptions = ["Raw", "Smooth", "Rate", "Constant"] as const;
type ModeOption = (typeof modeOptions)[number];

useEffect(() => {
setToyFeature(toy.features[selectedIndex] ?? toy.features[0]);
}, [toy, selectedIndex]);
Expand Down Expand Up @@ -112,7 +110,8 @@ export default function FeatureForm({
newParams[paramIndex].parameter =
`${OSC_PARAM_PREFIX}${e.target.value}`;
} else if (e.target.name == "osc_parameter_mode") {
newParams[paramIndex].processing_mode = e.target.value as ModeOption;
newParams[paramIndex].processing_mode = e.target
.value as FeProcessingMode;
}
const newF = {
...f,
Expand All @@ -123,6 +122,20 @@ export default function FeatureForm({
});
}

function handleInputProcessor(e: ChangeEvent<HTMLSelectElement>) {
setToyFeature((f) => {
const newF = {
...f,
penetration_system: {
...f.penetration_system,
[e.target.name]: e.target.value,
},
};
handleFeatureAlter(toy, newF);
return newF;
});
}

function handleLevels(key: keyof FeLevelTweaks, value: number) {
setToyFeature((feature) => {
return {
Expand Down Expand Up @@ -181,7 +194,7 @@ export default function FeatureForm({
onChange={(e) => {
handleOscParam(e, paramIndex);
}}
options={modeOptions}
options={ProcessingModes}
/>
<button
className="flex justify-center"
Expand Down Expand Up @@ -313,6 +326,32 @@ export default function FeatureForm({
levels.minimum_level * 100,
)}-${round0.format(levels.maximum_level * 100)}`}
/>
<FourPanel
text="Processor"
tooltip="The Input processor for this feature"
three={
<div className="flex gap-2">
<Select
name="pen_system_type"
value={feature.penetration_system.pen_system_type}
onChange={(e) => {
handleInputProcessor(e);
}}
options={PenetrationSystems}
/>
<Select
name="pen_system_processing_mode"
value={
feature.penetration_system.pen_system_processing_mode
}
onChange={(e) => {
handleInputProcessor(e);
}}
options={ProcessingModes}
/>
</div>
}
/>
{simulateEnabled != null && (
<FourPanel
text="Simulate"
Expand Down

0 comments on commit 2f1b13b

Please sign in to comment.