Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/game/GamePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
GameWarmup,
GameEmergencyStop,
GameSettings,
GameVibrator,
GameToyClient,
} from './components';
import { GameProvider } from './GameProvider';

Expand Down Expand Up @@ -89,7 +89,7 @@ export const GamePage = () => {
<GameIntensity />
<GamePace />
<GameSound />
<GameVibrator />
<GameToyClient />
<GameEvents />
</StyledLogicElements>
<GameImages />
Expand Down
43 changes: 43 additions & 0 deletions src/game/components/GameToyClient.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { useEffect, useState } from 'react';
import { GamePhase, useGameValue } from '../GameProvider';
import { useAutoRef } from '../../utils';
import { useToyClientValue } from '../../toy';

export const GameToyClient = () => {
const [stroke] = useGameValue('stroke');
const [intensity] = useGameValue('intensity');
const [pace] = useGameValue('pace');
const [phase] = useGameValue('phase');
const [devices] = useToyClientValue('devices');

const data = useAutoRef({
intensity,
pace,
devices,
});

const [currentPhase, setCurrentPhase] = useState(phase);

useEffect(() => {
const { intensity, pace, devices } = data.current;
devices.forEach(device => {
device.actuate(stroke, intensity, pace);
});
}, [data, stroke]);

useEffect(() => {
const { devices } = data.current;
if (currentPhase == phase) return;
switch (phase) {
case GamePhase.pause:
case GamePhase.break:
devices.forEach(device => device.stop());
break;
case GamePhase.climax:
devices.forEach(device => device.climax());
}
setCurrentPhase(phase);
}, [data, currentPhase, phase]);

return null;
};
72 changes: 0 additions & 72 deletions src/game/components/GameVibrator.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/game/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ export * from './GameMeter';
export * from './GamePace';
export * from './GameSettings';
export * from './GameSound';
export * from './GameVibrator';
export * from './GameToyClient';
export * from './GameWarmup';
6 changes: 3 additions & 3 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ import { App } from './app/App.tsx';
import './index.css';
import { SettingsProvider, ImageProvider } from './settings';
import { E621Provider } from './e621';
import { VibratorProvider } from './utils';
import { ToyClientProvider } from './toy';
import { LocalImageProvider } from './local/LocalProvider.tsx';

ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<SettingsProvider>
<ImageProvider>
<LocalImageProvider>
<VibratorProvider>
<ToyClientProvider>
<E621Provider>
<App />
</E621Provider>
</VibratorProvider>
</ToyClientProvider>
</LocalImageProvider>
</ImageProvider>
</SettingsProvider>
Expand Down
4 changes: 1 addition & 3 deletions src/settings/SettingsProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useCallback } from 'react';
import { GameEvent, GameHypnoType, PlayerBody, PlayerGender } from '../types';
import { createLocalStorageProvider, VibrationMode } from '../utils';
import { createLocalStorageProvider } from '../utils';
import { interpolateWith } from '../utils/translate';

export interface Settings {
Expand All @@ -18,7 +18,6 @@ export interface Settings {
body: PlayerBody;
highRes: boolean;
videoSound: boolean;
vibrations: VibrationMode;
}

export const defaultSettings: Settings = {
Expand All @@ -36,7 +35,6 @@ export const defaultSettings: Settings = {
body: PlayerBody.penis,
highRes: false,
videoSound: false,
vibrations: VibrationMode.thump,
};

const settingsStorageKey = 'settings';
Expand Down
110 changes: 110 additions & 0 deletions src/settings/components/ToyActuatorSettings.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import {
ToyActuator,
VibrationActuator,
ActuatorMode,
ActuatorModeLabels,
} from '../../toy';
import { PropsWithChildren, useState } from 'react';
import { SettingsTile } from '../../common';
import { SettingsDescription } from '../../common/SettingsDescription';
import { Dropdown } from '../../common/Dropdown';
import { ActuatorType } from 'buttplug';
import { Space } from '../../common/Space';
import { SettingsLabel } from '../../common/SettingsLabel';

export interface ToySettingsProps
extends PropsWithChildren<React.HTMLAttributes<HTMLFieldSetElement>> {
toyActuator: ToyActuator;
}

export const ToyActuatorSettings: React.FC<ToySettingsProps> = ({
toyActuator,
}) => {
return (
<SettingsTile
label={`${toyActuator.actuatorType} ${toyActuator.index + 1}`}
>
{(() => {
switch (toyActuator.actuatorType) {
case ActuatorType.Vibrate:
return <VibratorActuatorSettings toyActuator={toyActuator} />;
default:
return <UnknownActuatorSettings />;
}
})()}
</SettingsTile>
);
};

export const VibratorActuatorSettings: React.FC<ToySettingsProps> = ({
toyActuator,
}) => {
const vibratorActuator = toyActuator as VibrationActuator;
const descriptor = `${vibratorActuator.actuatorType}_${vibratorActuator.index}`;
const [mode, setMode] = useState(vibratorActuator.mode);
const [min, setMin] = useState(vibratorActuator.minIntensity);
const [max, setMax] = useState(vibratorActuator.maxIntensity);

return (
<div key={`${descriptor}_settings`}>
<SettingsDescription>
Select when this component will activate.
</SettingsDescription>
<Dropdown
id={`${descriptor}_mode`}
value={mode}
onChange={(value: string) => {
const newMode = value as ActuatorMode;
setMode(newMode);
vibratorActuator.setMode(newMode);
}}
options={Object.values(ActuatorMode).map(value => ({
value,
label: ActuatorModeLabels[value],
}))}
/>
<Space size='medium' />
<SettingsDescription>
Change the range of intensity for this component.
</SettingsDescription>
<SettingsLabel>From</SettingsLabel>
<Dropdown
id={`{${descriptor}_min}`}
value={`${min}`}
onChange={(value: string) => {
const newMin = +value;
if (newMin > vibratorActuator.maxIntensity) return;
setMin(newMin);
vibratorActuator.setMinIntensity(newMin);
}}
options={vibratorActuator.intensityRange.map(value => ({
value: `${value}`,
label: `${(value * 100).toFixed(0)}%`,
}))}
/>
<SettingsLabel>To</SettingsLabel>
<Dropdown
id={`{${descriptor}_max}`}
value={`${max}`}
onChange={(value: string) => {
const newMax = +value;
if (newMax < vibratorActuator.minIntensity) return;
setMax(newMax);
vibratorActuator.setMaxIntensity(newMax);
}}
options={vibratorActuator.intensityRange.map(value => ({
value: `${value}`,
label: `${(value * 100).toFixed(0)}%`,
}))}
/>
</div>
);
};

export const UnknownActuatorSettings = () => {
return (
<SettingsDescription>
This component is not currently supported.
</SettingsDescription>
);
};
Loading