mirror of
https://github.com/LinoSchmidt/StickExporterTX.git
synced 2026-03-21 01:51:15 +01:00
Added reset button to each setting
This commit is contained in:
@@ -114,19 +114,29 @@ function createProfile(profileName:string, clone:boolean) {
|
|||||||
writeSettings();
|
writeSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
function ProfileLoadDefault(profileName?:string) {
|
function ProfileLoadDefault(reset:{fps?:boolean, width?:boolean, stickDistance?:boolean, stickMode2?:boolean, videoFormat?:boolean, all?:boolean}, profileName?:string) {
|
||||||
if(profileName === undefined) {
|
if(profileName === undefined) {
|
||||||
profileName = getActiveProfile().profileName;
|
profileName = getActiveProfile().profileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
settingList.profiles.forEach(profile => {
|
settingList.profiles.forEach(profile => {
|
||||||
if(profile.profileName === profileName) {
|
if(profile.profileName === profileName) {
|
||||||
|
if(reset.all || reset.fps) {
|
||||||
profile.fps = defaultSettings.profiles[0].fps;
|
profile.fps = defaultSettings.profiles[0].fps;
|
||||||
|
}
|
||||||
|
if(reset.all || reset.width) {
|
||||||
profile.width = defaultSettings.profiles[0].width;
|
profile.width = defaultSettings.profiles[0].width;
|
||||||
|
}
|
||||||
|
if(reset.all || reset.stickDistance) {
|
||||||
profile.stickDistance = defaultSettings.profiles[0].stickDistance;
|
profile.stickDistance = defaultSettings.profiles[0].stickDistance;
|
||||||
|
}
|
||||||
|
if(reset.all || reset.stickMode2) {
|
||||||
profile.stickMode2 = defaultSettings.profiles[0].stickMode2;
|
profile.stickMode2 = defaultSettings.profiles[0].stickMode2;
|
||||||
|
}
|
||||||
|
if(reset.all || reset.videoFormat) {
|
||||||
profile.videoFormat = defaultSettings.profiles[0].videoFormat;
|
profile.videoFormat = defaultSettings.profiles[0].videoFormat;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
writeSettings();
|
writeSettings();
|
||||||
|
|||||||
@@ -8,10 +8,118 @@ let setRenderImg:React.Dispatch<React.SetStateAction<string>>;
|
|||||||
let setRenderLoading:React.Dispatch<React.SetStateAction<boolean>>;
|
let setRenderLoading:React.Dispatch<React.SetStateAction<boolean>>;
|
||||||
let pageLoaded = false;
|
let pageLoaded = false;
|
||||||
|
|
||||||
|
const VideoFormatOptions = Object.keys(VideoFormat).filter((el) => { return isNaN(Number(el)) }).map(key => {
|
||||||
|
return <option key={key} value={key}>{key}</option>;
|
||||||
|
});
|
||||||
|
|
||||||
function picturePath() {
|
function picturePath() {
|
||||||
return path.join(dataPath, "render.png?t="+Date.now());
|
return path.join(dataPath, "render.png?t="+Date.now());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const overlayArrowStyle:CSSProperties = {
|
||||||
|
width: "50%",
|
||||||
|
height: "50%",
|
||||||
|
fill: "white"
|
||||||
|
}
|
||||||
|
const settingLabelStyle:CSSProperties = {
|
||||||
|
position: "relative",
|
||||||
|
paddingLeft: "10px",
|
||||||
|
paddingRight: "10px",
|
||||||
|
height: "100%",
|
||||||
|
background: "#00c24a",
|
||||||
|
borderTopLeftRadius: "19px",
|
||||||
|
borderBottomLeftRadius: "19px",
|
||||||
|
fontWeight: "bolder",
|
||||||
|
overflow: "hidden",
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center"
|
||||||
|
}
|
||||||
|
|
||||||
|
function InputSpan({name, value, min, step, onChange, onReset}:{name:string, value:number, min:number, step:number, onChange:React.ChangeEventHandler<HTMLInputElement>, onReset:CallableFunction}) {
|
||||||
|
const [dispayOverlay, setDisplayOverlay] = useState("none");
|
||||||
|
|
||||||
|
return (
|
||||||
|
<span className="inputSelectSpan">
|
||||||
|
<div style={settingLabelStyle} onMouseEnter={() => {setDisplayOverlay("flex");}} onMouseLeave={() => {setDisplayOverlay("none");}}>
|
||||||
|
{name}
|
||||||
|
<div className="overlay" style={{display: dispayOverlay}} onClick={() => {onReset()}}>
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" style={overlayArrowStyle}>
|
||||||
|
{/* <!--! Font Awesome Pro 6.2.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. --> */}
|
||||||
|
<path d="M125.7 160H176c17.7 0 32 14.3 32 32s-14.3 32-32 32H48c-17.7 0-32-14.3-32-32V64c0-17.7 14.3-32 32-32s32 14.3 32 32v51.2L97.6 97.6c87.5-87.5 229.3-87.5 316.8 0s87.5 229.3 0 316.8s-229.3 87.5-316.8 0c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0c62.5 62.5 163.8 62.5 226.3 0s62.5-163.8 0-226.3s-163.8-62.5-226.3 0L125.7 160z"/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<input id={name+" Input"} type="number" value={value.toString()} min={min.toString()} step={step.toString()} onChange={onChange}/>
|
||||||
|
</span>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function SelectSpan({name, value, optiones, onChange, onReset}:{name:string, value:string, optiones:JSX.Element[], onChange:React.ChangeEventHandler<HTMLSelectElement>, onReset:CallableFunction}) {
|
||||||
|
const [dispayOverlay, setDisplayOverlay] = useState("none");
|
||||||
|
|
||||||
|
return (
|
||||||
|
<span className="inputSelectSpan">
|
||||||
|
<div style={settingLabelStyle} onMouseEnter={() => {setDisplayOverlay("flex");}} onMouseLeave={() => {setDisplayOverlay("none");}}>
|
||||||
|
{name}
|
||||||
|
<div className="overlay" style={{display: dispayOverlay}} onClick={() => {onReset()}}>
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" style={overlayArrowStyle}>
|
||||||
|
{/* <!--! Font Awesome Pro 6.2.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. --> */}
|
||||||
|
<path d="M125.7 160H176c17.7 0 32 14.3 32 32s-14.3 32-32 32H48c-17.7 0-32-14.3-32-32V64c0-17.7 14.3-32 32-32s32 14.3 32 32v51.2L97.6 97.6c87.5-87.5 229.3-87.5 316.8 0s87.5 229.3 0 316.8s-229.3 87.5-316.8 0c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0c62.5 62.5 163.8 62.5 226.3 0s62.5-163.8 0-226.3s-163.8-62.5-226.3 0L125.7 160z"/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<select id={name+" slct"} required={true} value={value} onChange={onChange}>
|
||||||
|
{optiones}
|
||||||
|
</select>
|
||||||
|
</span>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function ToggleSpan({name, state, checkedValue, uncheckedValue, onChange, onReset}:{name:string, state:boolean, checkedValue:string, uncheckedValue:string, onChange(checked:boolean):void, onReset:CallableFunction}) {
|
||||||
|
const [dispayOverlay, setDisplayOverlay] = useState("none");
|
||||||
|
const [checked, setChecked] = useState(state);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setChecked(state);
|
||||||
|
}, [state]);
|
||||||
|
|
||||||
|
const toggleStyle:CSSProperties = {
|
||||||
|
height: "100%",
|
||||||
|
border: "0",
|
||||||
|
borderTopRightRadius: "18px",
|
||||||
|
borderBottomRightRadius: "18px",
|
||||||
|
textAlign: "center",
|
||||||
|
fontSize: "large",
|
||||||
|
paddingLeft: "15px",
|
||||||
|
paddingRight: "15px",
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
backgroundColor: checked ? "#2196F3" : "white",
|
||||||
|
color: checked ? "white" : "black",
|
||||||
|
cursor: "pointer"
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<span className="inputSelectSpan">
|
||||||
|
<div style={settingLabelStyle} onMouseEnter={() => {setDisplayOverlay("flex");}} onMouseLeave={() => {setDisplayOverlay("none");}}>
|
||||||
|
{name}
|
||||||
|
<div className="overlay" style={{display: dispayOverlay}} onClick={() => {onReset()}}>
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" style={overlayArrowStyle}>
|
||||||
|
{/* <!--! Font Awesome Pro 6.2.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. --> */}
|
||||||
|
<path d="M125.7 160H176c17.7 0 32 14.3 32 32s-14.3 32-32 32H48c-17.7 0-32-14.3-32-32V64c0-17.7 14.3-32 32-32s32 14.3 32 32v51.2L97.6 97.6c87.5-87.5 229.3-87.5 316.8 0s87.5 229.3 0 316.8s-229.3 87.5-316.8 0c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0c62.5 62.5 163.8 62.5 226.3 0s62.5-163.8 0-226.3s-163.8-62.5-226.3 0L125.7 160z"/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div style={toggleStyle} onClick={() => {
|
||||||
|
onChange(!checked);
|
||||||
|
setChecked(!checked);
|
||||||
|
}}>
|
||||||
|
{checked ? checkedValue : uncheckedValue}
|
||||||
|
</div>
|
||||||
|
</span>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
const RenderLoadingSpinner = () => (
|
const RenderLoadingSpinner = () => (
|
||||||
<div id="renderLoadingDiv">
|
<div id="renderLoadingDiv">
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
|
||||||
@@ -88,59 +196,57 @@ function SettingsPage() {
|
|||||||
|
|
||||||
pageLoaded = true;
|
pageLoaded = true;
|
||||||
|
|
||||||
const VideoFormatOptions = Object.keys(VideoFormat).filter((el) => { return isNaN(Number(el)) }).map(key => {
|
|
||||||
return <option key={key} value={key}>{key}</option>;
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div id="content">
|
<div id="content">
|
||||||
<div id="settingRow">
|
<div id="settingRow">
|
||||||
<span className="inputSpan">
|
{<InputSpan name={"FPS"} value={fps} min={1} step={1} onChange={
|
||||||
<label>FPS</label>
|
e => {
|
||||||
<input id="fpsInput" type="number" value={fps.toString()} min="1" step="1" onChange={e => {
|
|
||||||
if(e.target.value.trim().length !== 0) setFps(parseInt(e.target.value));
|
if(e.target.value.trim().length !== 0) setFps(parseInt(e.target.value));
|
||||||
}}/>
|
}
|
||||||
</span>
|
} onReset={() => {
|
||||||
<span className="inputSpan">
|
ProfileLoadDefault({fps: true});
|
||||||
<label>Width</label>
|
setFps(getActiveProfile().fps);
|
||||||
<input id="widthInput" type="number" value={width.toString()} min="1" step="1" onChange={e => {
|
}}/>}
|
||||||
|
{<InputSpan name="Width" value={width} min={1} step={1} onChange={
|
||||||
|
e => {
|
||||||
if(e.target.value.trim().length !== 0) setWidth(parseInt(e.target.value));
|
if(e.target.value.trim().length !== 0) setWidth(parseInt(e.target.value));
|
||||||
}}/>
|
}
|
||||||
</span>
|
} onReset={() => {
|
||||||
<span className="inputSpan">
|
ProfileLoadDefault({width: true});
|
||||||
<label>Stick Distance</label>
|
setWidth(getActiveProfile().width);
|
||||||
<input id="stickDistanceInput" type="number" value={stickDistance.toString()} min="0" step="1" onChange={e => {
|
}}/>}
|
||||||
|
{<InputSpan name="Stick Distance" value={stickDistance} min={0} step={1} onChange={
|
||||||
|
e => {
|
||||||
if(e.target.value.trim().length !== 0) setStickDistance(parseInt(e.target.value));
|
if(e.target.value.trim().length !== 0) setStickDistance(parseInt(e.target.value));
|
||||||
}}/>
|
}
|
||||||
</span>
|
} onReset={() => {
|
||||||
|
ProfileLoadDefault({stickDistance: true});
|
||||||
|
setStickDistance(getActiveProfile().stickDistance);
|
||||||
|
}}/>}
|
||||||
</div>
|
</div>
|
||||||
<div id="settingRow">
|
<div id="settingRow">
|
||||||
<div className="dataDiv">
|
{<ToggleSpan name="Stick Mode" state={stickMode2} checkedValue={"2"} uncheckedValue={"1"} onChange={checked => {
|
||||||
<p>Stick Mode</p>
|
setStickMode2(checked);
|
||||||
<label htmlFor="stickMode" className="toggle-switchy" data-style="rounded" data-text="12">
|
}} onReset={() => {
|
||||||
<input checked={stickMode2} type="checkbox" id="stickMode" onChange={e => {
|
ProfileLoadDefault({stickMode2: true});
|
||||||
setStickMode2(e.target.checked);
|
setStickMode2(getActiveProfile().stickMode2);
|
||||||
}}/>
|
}}/>}
|
||||||
<span className="toggle">
|
<div style={{
|
||||||
<span className="switch"></span>
|
display: "flex",
|
||||||
</span>
|
alignItems: "center",
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<span className="selectSpan">
|
|
||||||
<label className="selectSpanLabel">Format</label>
|
|
||||||
<label className="selectSpanSelect" htmlFor="slct">
|
|
||||||
<select id="slct" required={true} value={videoFormat} onChange={e => {
|
|
||||||
setVideoFormat(e.target.value as unknown as VideoFormat);
|
|
||||||
}}>
|
}}>
|
||||||
{VideoFormatOptions}
|
{<SelectSpan name="Format" value={videoFormat} optiones={VideoFormatOptions} onChange={ e => {
|
||||||
</select>
|
setVideoFormat(e.target.value as unknown as VideoFormat);
|
||||||
</label>
|
}} onReset={() => {
|
||||||
|
ProfileLoadDefault({videoFormat: true});
|
||||||
|
setVideoFormat(getActiveProfile().videoFormat);
|
||||||
|
}}/>}
|
||||||
{videoFormat === VideoFormat.mov? <VideoFormatWarning videoFormat={videoFormat}/> : null}
|
{videoFormat === VideoFormat.mov? <VideoFormatWarning videoFormat={videoFormat}/> : null}
|
||||||
{videoFormat === VideoFormat.mp4? <VideoFormatWarning videoFormat={videoFormat}/> : null}
|
{videoFormat === VideoFormat.mp4? <VideoFormatWarning videoFormat={videoFormat}/> : null}
|
||||||
{videoFormat === VideoFormat.avi? <VideoFormatWarning videoFormat={videoFormat}/> : null}
|
{videoFormat === VideoFormat.avi? <VideoFormatWarning videoFormat={videoFormat}/> : null}
|
||||||
</span>
|
</div>
|
||||||
<button id="resetSettingsButton" onClick={() => {
|
<button id="resetSettingsButton" onClick={() => {
|
||||||
ProfileLoadDefault();
|
ProfileLoadDefault({all: true});
|
||||||
|
|
||||||
setFps(getActiveProfile().fps);
|
setFps(getActiveProfile().fps);
|
||||||
setWidth(getActiveProfile().width);
|
setWidth(getActiveProfile().width);
|
||||||
|
|||||||
@@ -321,38 +321,64 @@ button:hover {
|
|||||||
transform: scale(1.05);
|
transform: scale(1.05);
|
||||||
}
|
}
|
||||||
|
|
||||||
.inputSpan {
|
.inputSelectSpan {
|
||||||
position: relative;
|
position: relative;
|
||||||
display: inline-block;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding-bottom: 15px;
|
height: 35px;
|
||||||
|
margin-bottom: 15px;
|
||||||
}
|
}
|
||||||
.inputSpan input {
|
.inputSelectSpan input {
|
||||||
width: 75px;
|
width: 75px;
|
||||||
padding: 8px 0;
|
height: 100%;
|
||||||
border: 0;
|
border: 0;
|
||||||
border-top-right-radius: 18px;
|
border-top-right-radius: 18px;
|
||||||
border-bottom-right-radius: 18px;
|
border-bottom-right-radius: 18px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: large;
|
font-size: large;
|
||||||
line-height: 0px;
|
padding: 0;
|
||||||
}
|
}
|
||||||
.inputSpan label {
|
.inputSelectSpan label {
|
||||||
padding: 10px 10px;
|
padding-left: 10px;
|
||||||
|
padding-right: 10px;
|
||||||
|
height: 100%;
|
||||||
background: #00c24a;
|
background: #00c24a;
|
||||||
border-top-left-radius: 18px;
|
border-top-left-radius: 18px;
|
||||||
border-bottom-left-radius: 18px;
|
border-bottom-left-radius: 18px;
|
||||||
font-weight: bolder;
|
font-weight: bolder;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.inputSelectSpan select {
|
||||||
|
height: 100%;
|
||||||
|
border: 0;
|
||||||
|
border-top-right-radius: 18px;
|
||||||
|
border-bottom-right-radius: 18px;
|
||||||
|
cursor: pointer;
|
||||||
|
text-align: center;
|
||||||
|
font-size: large;
|
||||||
|
}
|
||||||
|
|
||||||
|
.overlay {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background-color: rgba(0,0,0,0.8);
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
#settingRow {
|
#settingRow {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-around;
|
justify-content: space-around;
|
||||||
align-items: center;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#resetSettingsButton {
|
#resetSettingsButton {
|
||||||
height: 35px;
|
height: 35px;
|
||||||
|
background-color: #e1334e;
|
||||||
}
|
}
|
||||||
|
|
||||||
#logList-Name:hover {
|
#logList-Name:hover {
|
||||||
@@ -421,22 +447,7 @@ button:hover {
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
.selectSpanSelect select {
|
|
||||||
padding: 8px 0;
|
|
||||||
border: 0;
|
|
||||||
border-top-right-radius: 18px;
|
|
||||||
border-bottom-right-radius: 18px;
|
|
||||||
cursor: pointer;
|
|
||||||
text-align: center;
|
|
||||||
font-size: large;
|
|
||||||
}
|
|
||||||
.selectSpanLabel {
|
|
||||||
padding: 10px 10px;
|
|
||||||
background: #00c24a;
|
|
||||||
border-top-left-radius: 18px;
|
|
||||||
border-bottom-left-radius: 18px;
|
|
||||||
font-weight: bolder;
|
|
||||||
}
|
|
||||||
#videoFormatWarning:hover {
|
#videoFormatWarning:hover {
|
||||||
transform: scale(1.05);
|
transform: scale(1.05);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user