New settings layout + update solarxr

This commit is contained in:
lucas lelievre committed 2022-04-25 20:06:25 +02:00
1 parent 4906d9551e
commit 17d75cfee0
18 files changed
+238 -87

No files matched your search

@@ -1,5 +1,8 @@
@echo off
setlocal enableextensions
echo "TEST"
cd /d "C:\Program Files (x86)\SlimeVR Server"
jre\bin\java.exe -Xmx512M -jar slimevr.jar --no-gui
+1 -1
View File
@@ -4,7 +4,7 @@
)]
use std::path::PathBuf;
use std::process::Command;
use std::process::{Command};
// the payload type must implement `Serialize` and `Clone`.
+3 -1
View File
@@ -53,7 +53,9 @@
"width": 1150,
"height": 660,
"resizable": true,
"fullscreen": false
"fullscreen": false,
"decorations": false,
"transparent": true
}
],
"security": {
+23 -48
View File
@@ -1,4 +1,3 @@
import { Navbar } from './components/Navbar';
import { useProvideWebsocketApi, useWebsocketAPI, WebSocketApiContext } from './hooks/websocket-api';
import {
BrowserRouter as Router,
@@ -6,23 +5,15 @@ import {
Route,
} from "react-router-dom";
import { Overview } from './components/Overview';
import { BigButton } from './components/commons/BigButton';
import { QuickResetIcon, ResetIcon } from './components/commons/icon/ResetIcon';
import { useReset } from './hooks/reset';
import { Button } from './components/commons/Button';
import { useLayout } from './hooks/layout';
import { BodyProportions } from './components/proportions/BodyProportions';
import { BVHButton } from './components/BVHButton';
import { AppContextProvider } from './components/providers/AppContext';
import { useEffect } from 'react';
import { DataFeedConfigT, DataFeedMessage, DeviceDataMaskT, ResetType, StartDataFeedT, TrackerDataMaskT } from 'solarxr-protocol';
import { Settings } from './components/Settings';
import { DataFeedConfigT, DataFeedMessage, DeviceDataMaskT, StartDataFeedT, TrackerDataMaskT } from 'solarxr-protocol';
import { Settings } from './components/settings/Settings';
import { MainLayoutRoute } from './components/MainLayout';
import { SettingsLayoutRoute } from './components/settings/SettingsLayout';
function Layout() {
const { layoutHeight, ref } = useLayout();
const { reset, timer, reseting } = useReset()
const { sendDataFeedPacket } = useWebsocketAPI();
useEffect(() => {
@@ -47,36 +38,25 @@ function Layout() {
sendDataFeedPacket(DataFeedMessage.StartDataFeed, startDataFeed)
}, [])
return (
<>
<div ref={ref} className='flex-grow' style={{ height: layoutHeight }}>
<div className="flex bg-primary-1 h-full ">
<div className="flex flex-grow gap-10 flex-col bg-primary-2 rounded-tr-3xl">
<Routes>
<Route path="/" element={<Overview/>}/>
<Route path="/proportions" element={<BodyProportions/>}/>
<Route path="/settings" element={<Settings/>}/>
</Routes>
</div>
<div className="flex flex-col px-8 w-60 gap-8 pb-5 overflow-y-auto">
<div className='flex'>
<BigButton text={"Fast reset"} icon={<QuickResetIcon/>} onClick={() => reset(ResetType.Quick)} ></BigButton>
</div>
<div className='flex'>
<BigButton text={!reseting ? "Reset" : `${3 - timer}`} icon={<ResetIcon />} onClick={() => reset(ResetType.Full)} disabled={reseting}></BigButton>
</div>
<div className='flex'>
<BVHButton></BVHButton>
</div>
<div className='flex flex-grow flex-col justify-end'>
<Button variant='primary' className='w-full'>Debug</Button>
</div>
</div>
</div>
</div>
<Routes>
<Route path="/" element={
<MainLayoutRoute>
<Overview/>
</MainLayoutRoute>
}/>
<Route path="/proportions" element={
<MainLayoutRoute>
<BodyProportions/>
</MainLayoutRoute>
}/>
<Route path="/settings" element={
<SettingsLayoutRoute>
<Settings/>
</SettingsLayoutRoute>
}/>
</Routes>
</>
)
}
@@ -88,15 +68,10 @@ function App() {
<WebSocketApiContext.Provider value={websocketAPI}>
<AppContextProvider>
<Router>
<div className='bg-primary h-full w-full overflow-hidden'>
<div className='bg-primary-1 h-full w-full overflow-hidden'>
<div className='flex-col h-full'>
{!websocketAPI.isConnected && <div className='flex w-full h-full justify-center items-center text-white p-2'>Connection lost to server</div>}
{websocketAPI.isConnected &&
<>
<Navbar></Navbar>
<Layout></Layout>
</>
}
{websocketAPI.isConnected && <Layout></Layout>}
</div>
</div>
</Router>
+52
View File
@@ -0,0 +1,52 @@
import { ReactChild } from "react";
import { NavLink } from "react-router-dom";
import { ResetType } from "solarxr-protocol";
import { useLayout } from "../hooks/layout";
import { BVHButton } from "./BVHButton";
import { Button } from "./commons/Button";
import { CubeIcon } from "./commons/icon/CubeIcon";
import { GearIcon } from "./commons/icon/GearIcon";
import { Navbar, NavButton } from "./Navbar";
import { ResetButton } from "./ResetButton";
export function MainLayoutRoute({ children }: { children: ReactChild }) {
const { layoutHeight, ref } = useLayout();
return (
<>
<Navbar>
<>
<NavButton to="/" icon={<CubeIcon></CubeIcon>}>Overview</NavButton>
<NavButton to="/proportions" icon={<GearIcon></GearIcon>}>Body proportions</NavButton>
</>
</Navbar>
<div ref={ref} className='flex-grow' style={{ height: layoutHeight }}>
<div className="flex bg-primary-1 h-full ">
<div className="flex flex-grow gap-10 flex-col bg-primary-2 rounded-tr-3xl">
{children}
</div>
<div className="flex flex-col px-8 w-60 gap-8 pb-5 overflow-y-auto">
<div className='flex'>
<ResetButton type={ResetType.Quick}></ResetButton>
</div>
<div className='flex'>
<ResetButton type={ResetType.Full}></ResetButton>
</div>
<div className='flex'>
<BVHButton></BVHButton>
</div>
<div className='flex flex-grow flex-col justify-end'>
{/* <Button variant='primary' className='w-full'>Debug</Button> */}
<NavLink to="/settings" className="flex gap-5 group cursor-pointer">
<div className="flex bg-primary-4 rounded-full p-2 fill-purple-300 group-hover:fill-white"><GearIcon></GearIcon></div>
<div className="flex flex-col justify-around text-purple-300 group-hover:text-white font-bold">Settings</div>
</NavLink>
</div>
</div>
</div>
</div>
</>
)
}
+27 -13
View File
@@ -7,6 +7,11 @@ import {
import { CubeIcon } from './commons/icon/CubeIcon';
import { GearIcon } from './commons/icon/GearIcon';
import { SlimeVRIcon } from './commons/icon/SimevrIcon';
import { appWindow } from '@tauri-apps/api/window'
import { MinimiseIcon } from './commons/icon/MinimiseIcon';
import { MaximiseIcon } from './commons/icon/MaximiseIcon';
import { CloseIcon } from './commons/icon/CloseIcon';
import { useWebsocketAPI } from '../hooks/websocket-api';
export function NavButton({ to, children, match, icon }: { to: string, children: ReactChild, match?: string, icon: ReactChild }) {
@@ -16,31 +21,40 @@ export function NavButton({ to, children, match, icon }: { to: string, children:
});
return (
<NavLink to={to} className={classnames("flex flex-grow flex-row gap-3 py-3 px-8 rounded-t-md group font-bold", { 'bg-primary-2 ': doesMatch, 'hover:bg-primary-3': !doesMatch })}>
<NavLink to={to} className={classnames("flex flex-grow flex-row gap-3 py-3 px-8 rounded-t-md group font-bold select-text", { 'bg-primary-2 ': doesMatch, 'hover:bg-primary-3': !doesMatch })}>
<div className="flex align-middle justify-center justify-items-center flex-col">
<div className={classnames("fill-primary-3 group-hover:fill-white", { 'fill-misc-3': doesMatch })}>{icon}</div>
</div>
<div className={classnames("flex text-md ", { 'text-white': doesMatch, 'text-gray-400': !doesMatch })}>{children}</div>
</NavLink >
</NavLink>
)
}
export function Navbar() {
export function Navbar({ children }: { children?: ReactChild }) {
return (
<div className='flex bg-primary-1 gap-2'>
<div className="flex px-8 py-2 justify-around">
<div className="flex flex-row gap-3">
<div className="flex justify-around flex-col">
<SlimeVRIcon></SlimeVRIcon>
<div data-tauri-drag-region className='flex bg-primary-1 gap-2'>
<div className="flex px-8 py-2 pt-3 justify-around" data-tauri-drag-region>
<div className="flex flex-row gap-3" data-tauri-drag-region>
<div className="flex justify-around flex-col select-all" data-tauri-drag-region>
<SlimeVRIcon drag></SlimeVRIcon>
</div>
<div className="flex text-white text-xl justify-around flex-col font-bold">SlimeVR</div>
<div className="flex text-white text-xl justify-around flex-col font-bold" data-tauri-drag-region>SlimeVR</div>
</div>
</div>
<div className="flex px-5 gap-2 pt-2">
<NavButton to="/" icon={<CubeIcon></CubeIcon>}>Overview</NavButton>
<NavButton to="/proportions" icon={<GearIcon></GearIcon>}>Body proportions</NavButton>
<NavButton to="/settings" icon={<GearIcon></GearIcon>}>Settings</NavButton>
{children && <div className="flex px-5 gap-2 pt-2">
{children}
</div>}
<div className="flex flex-grow justify-end px-2 gap-2" data-tauri-drag-region>
<div className='flex flex-col justify-around text-white' onClick={() => appWindow.minimize()}>
<MinimiseIcon className="hover:bg-primary-5 rounded-full"></MinimiseIcon>
</div>
<div className='flex flex-col justify-around text-white' onClick={() => appWindow.maximize()}>
<MaximiseIcon className="hover:bg-primary-5 rounded-full"></MaximiseIcon>
</div>
<div className='flex flex-col justify-around text-white' onClick={() => appWindow.close()}>
<CloseIcon className="hover:bg-primary-5 rounded-full"></CloseIcon>
</div>
</div>
</div>
)
+1 -1
View File
@@ -35,7 +35,7 @@ export function Overview() {
return (
<div className="overflow-y-auto flex flex-col gap-8">
<div className="flex text-white text-2xl px-8 pt-8 font-bold">
Tracker Overview
Assigned Trackers
</div>
<div className="grid md:grid-cols-2 lg:grid-cols-3 gap-5 sm:grid-cols-1 px-8">
{asignedTrackers.map(({ tracker, device }, index) => <TrackerCard key={index} tracker={tracker} device={device}/>)}
@@ -1,16 +1,19 @@
import { useRef, useState } from "react";
import { ResetRequestT, ResetType, RpcMessage } from "solarxr-protocol";
import { useWebsocketAPI } from "./websocket-api";
import { useWebsocketAPI } from "../hooks/websocket-api";
import { BigButton } from "./commons/BigButton";
import { QuickResetIcon, ResetIcon } from "./commons/icon/ResetIcon";
export function useReset() {
export function ResetButton({ type }: { type: ResetType }) {
const timerid = useRef<NodeJS.Timer | null>(null);
const [reseting, setReseting] = useState(false);
const [timer, setTimer] = useState(0);
const { sendRPCPacket } = useWebsocketAPI();
const reset = (type: ResetType) => {
const reset = () => {
const req = new ResetRequestT();
req.resetType = type;
setReseting(true);
@@ -35,9 +38,13 @@ export function useReset() {
}
}
return {
reset,
timer,
reseting
}
return (
<BigButton
text={!reseting ? "Reset" : `${3 - timer}`} icon={type === ResetType.Quick ? <QuickResetIcon /> : <ResetIcon/>}
onClick={reset}
disabled={reseting}>
</BigButton>
)
}
+11
View File
@@ -0,0 +1,11 @@
export function CloseIcon({ className }: { className?: string }) {
return (
<svg width="35" height="35" className={className} viewBox="0 0 31 29" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M19.3804 17.8804L12.619 11.119" stroke="#C0A1D8" strokeLinecap="round"/>
<path d="M12.6196 17.8804L19.381 11.119" stroke="#C0A1D8" strokeLinecap="round"/>
</svg>
)
}
@@ -0,0 +1,10 @@
export function MaximiseIcon({ className }: { className?: string }) {
return (
<svg width="35" height="35" className={className} viewBox="0 0 31 29" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M18 11.5H14C13.1716 11.5 12.5 12.1716 12.5 13V17C12.5 17.8284 13.1716 18.5 14 18.5H18C18.8284 18.5 19.5 17.8284 19.5 17V13C19.5 12.1716 18.8284 11.5 18 11.5Z" stroke="#C0A1D8"/>
</svg>
)
}
@@ -0,0 +1,10 @@
export function MinimiseIcon({ className }: { className?: string }) {
return (
<svg width="35" height="35" className={className} viewBox="0 0 31 29" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M20.5 15.5H10.5" stroke="#C0A1D8" strokeLinecap="round"/>
</svg>
)
}
+2 -2
View File
@@ -1,9 +1,9 @@
export function SlimeVRIcon() {
export function SlimeVRIcon({ drag }: { drag: boolean }) {
return (
<svg width="49" height="29" viewBox="0 0 49 29" fill="none" xmlns="http://www.w3.org/2000/svg">
<svg width="49" height="29" viewBox="0 0 49 29" fill="none" xmlns="http://www.w3.org/2000/svg" data-tauri-drag-region>
<path d="M2 26.996C10.44 25.59 29.16 23.1571 46.509 26.9091C46.509 26.9091 48.89 -0.199966 35.761 2.14503" stroke="#A44FED" strokeWidth="3" strokeLinecap="round"/>
<path d="M7.52161 15.0107L12.3649 9.20459L17.5044 13.9572" stroke="#A44FED" strokeWidth="3.00157" strokeLinecap="round"/>
<path d="M27.9566 14.1435L33.7372 9.27062L37.9695 14.8458" stroke="#A44FED" strokeWidth="3.00136" strokeLinecap="round"/>
@@ -25,8 +25,11 @@ const bodyPartLabels = {
[SkeletonBone.SKELETON_OFFSET]: "Skeleton offset",
[SkeletonBone.CONTROLLER_DISTANCE_Z]: "Controller distance z",
[SkeletonBone.CONTROLLER_DISTANCE_Y]: "Controller distance y",
[SkeletonBone.ELBOW_DISTANCE]: "Elbow distance",
[SkeletonBone.UPPER_ARM_DISTANCE]: "Upper arm distance"
[SkeletonBone.FOREARM_LENGTH]: "Forearm distance",
[SkeletonBone.SHOULDERS_DISTANCE]: "Shoulders distance",
[SkeletonBone.SHOULDERS_WIDTH]: "Shoulders width",
[SkeletonBone.UPPER_ARM_LENGTH]: "Upper arm length",
[SkeletonBone.ELBOW_OFFSET]: "Elbow offset"
}
type BodyProportionsForm = ({ [key: string]: number });
@@ -102,8 +105,8 @@ export function BodyProportions() {
<div className="flex text-2xl px-8 pt-8 text-white font-bold">
Body Proportions
</div>
<div className="flex p-5 gap-8 h-full justify-center">
<div className="bg-primary-1 rounded-lg w-72 justify-center p-10 hidden sm:flex">
<div className="flex p-5 gap-8 justify-center">
<div className="bg-primary-1 h-1/2 sticky top-5 rounded-lg w-72 justify-center p-10 hidden sm:flex">
<BodyView selectedBodyPart={selectedBodyPart || 0}></BodyView>
</div>
<div className="flex-col flex gap-4">
+1 -1
View File
@@ -24,7 +24,7 @@ export function BodyView({ selectedBodyPart }: { selectedBodyPart: number }) {
}
{selectedBodyPart === SkeletonBone.KNEE_HEIGHT &&
<>
<path d="M11.2487 439L11.2487 521.364" stroke="#8E6BA7" stroke-width="2"/>
<path d="M11.2487 439L11.2487 521.364" stroke="#8E6BA7" strokeWidth="2"/>
<path d="M0 522H23M0 439H23" stroke="#8E6BA7" strokeWidth="2"/>
</>
@@ -1,10 +1,10 @@
import { useWebsocketAPI } from "../hooks/websocket-api";
import { CheckBox } from "./commons/Checkbox";
import { useWebsocketAPI } from "../../hooks/websocket-api";
import { CheckBox } from "../commons/Checkbox";
import { useForm } from "react-hook-form";
import { useEffect } from "react";
import { Select } from "./commons/Select";
import { NumberSelector } from "./commons/NumberSelector";
import { WIFIButton } from "./WifiButton";
import { Select } from "../commons/Select";
import { NumberSelector } from "../commons/NumberSelector";
import { WIFIButton } from "../WifiButton";
import { ChangeSettingsRequestT, FilteringSettingsT, RpcMessage, SettingsRequestT, SettingsResponseT, SteamVRTrackersSettingT } from "solarxr-protocol";
interface SettingsForm {
@@ -37,7 +37,6 @@ export function Settings() {
trackers.legs = values.trackers.legs;
trackers.knees = values.trackers.knees;
trackers.elbows = values.trackers.elbows;
settings.steamVrTrackers = trackers;
}
@@ -0,0 +1,33 @@
import { ReactChild } from "react";
import { NavLink } from "react-router-dom";
import { useLayout } from "../../hooks/layout";
import { IconButton } from "../commons/ButtonIcon";
import { CloseIcon } from "../commons/icon/CloseIcon";
import { Navbar } from "../Navbar";
import { SettingsSidebar } from "./SettingsSidebar";
export function SettingsLayoutRoute({ children }: { children: ReactChild }) {
const { layoutHeight, ref } = useLayout();
return (
<>
<Navbar></Navbar>
<div ref={ref} className='flex-grow' style={{ height: layoutHeight }}>
<div className="flex bg-primary-1 h-full ">
<SettingsSidebar></SettingsSidebar>
<div className="flex flex-grow gap-10 flex-col bg-primary-2 rounded-tl-3xl">
<div className="relative">
{children}
<div className="absolute top-0 right-0 p-5">
<NavLink to="/" className="flex gap-5 group cursor-pointer">
<div className="flex bg-primary-4 rounded-full p-2 fill-purple-300 group-hover:fill-white"><CloseIcon></CloseIcon></div>
</NavLink>
</div>
</div>
</div>
</div>
</div>
</>
)
}
@@ -0,0 +1,24 @@
import { NavLink } from "react-router-dom"
export function SettingsSidebar() {
return (
<div className="flex flex-col px-8 w-72 gap-8 pb-5 overflow-y-auto">
<div className="flex flex-col gap-3 pt-4 text-purple-100 font-bold">
<div className="flex">TRACKER SETTINGS</div>
<div className="flex flex-col gap-2 font-medium">
<NavLink to="/settings/tracker/steamvr" className="pl-5 py-2 hover:bg-primary-5 rounded-lg">SteamVR</NavLink>
<NavLink to="/settings/tracker/steamvr" className="pl-5 py-2 hover:bg-primary-5 rounded-lg">Filtering</NavLink>
</div>
</div>
<div className="flex flex-col gap-3 pt-4 text-purple-100 font-bold">
<div className="flex">USER INTERFACE</div>
<div className="flex flex-col gap-2 font-medium">
<NavLink to="" className="pl-3 py-2 hover:bg-primary-5 rounded-lg">Widgets</NavLink>
</div>
</div>
</div>
)
}
+10 -2
View File
@@ -3,13 +3,21 @@
@tailwind utilities;
body {
background-color: theme('colors.primary.1');
font-variant-numeric: tabular-nums;
height: 100vh;
width: 100vw;
user-select: none;
overflow: hidden;
border-radius: 15px;
}
html {
overflow: hidden;
border-radius: 15px;
}
#root {
height: 100%;
}
}