New Top Bar design

This commit is contained in:
2022-06-22 20:10:26 +02:00
parent ade3cdd6fe
commit 7b67559589
7 changed files with 72 additions and 77 deletions

View File

@@ -1,16 +1,17 @@
import {spawn} from 'child_process';
import logger from './logger';
import { Platform, platform } from './platform';
export default function openFolder(path:string) {
if (process.platform === 'darwin') {
if (platform === Platform.Mac) {
spawn('open', [path]).on('error', (err) => {
logger.errorMSG(err.message);
});
} else if (process.platform === 'win32') {
} else if (platform === Platform.Windows) {
spawn('explorer', [path]).on('error', (err) => {
logger.errorMSG(err.message);
});
} else if (process.platform === 'linux') {
} else if (platform === Platform.Linux) {
spawn('xdg-open', [path]).on('error', (err) => {
logger.errorMSG(err.message);
});

View File

@@ -1,5 +1,6 @@
import path from 'path';
import {app} from '@electron/remote';
import { platformFolder, platform, Platform } from './platform';
export const dataPath = app.getPath('userData');
export const appPath = app.getAppPath().replace("app.asar", "");
@@ -7,18 +8,9 @@ export const SettingPath = path.join(dataPath, "settings.xml");
export const defaultOutputPath = path.join(app.getPath('videos'), "StickExporterTX");
let platformFolder = "";
if(process.platform === "win32") {
platformFolder = "windows";
} else if(process.platform === "darwin") {
platformFolder = "darwin";
} else if(process.platform === "linux") {
platformFolder = "linux";
}
export function platformCharacter() {
let platformCharacterTEMP = "/";
if (process.platform === "win32") {
if (platform === Platform.Windows) {
platformCharacterTEMP = "\\";
}
return platformCharacterTEMP;

View File

@@ -0,0 +1,15 @@
const enum Platform {
Windows = 'win32',
Mac = 'darwin',
Linux = 'linux'
}
const platform = process.platform;
const platformFolder = platform === Platform.Windows ? 'windows' : platform === Platform.Mac ? 'darwin' : 'linux';
export {
platform,
Platform,
platformFolder
}

View File

@@ -16,13 +16,14 @@ const defaultSettings = {
output: defaultOutputPath
}
let loadedSuccessfully = true;
const settingList = await fetch(SettingPath).then(function(response){
let loadedSuccessfully = false;
const settingList = await fetch(SettingPath).then(function(response) {
return response.text();
}).then(function(data){
}).then(function(data) {
const parser = new DOMParser();
const xmlDoc = parser.parseFromString(data, 'text/xml');
loadedSuccessfully = true;
return {
fps: parseInt(getXMLChild(xmlDoc, "fps")),
width: parseInt(getXMLChild(xmlDoc, "width")),
@@ -31,23 +32,12 @@ const settingList = await fetch(SettingPath).then(function(response){
log: (getXMLChild(xmlDoc, "log") === "None")? "":getXMLChild(xmlDoc, "log"),
output: getXMLChild(xmlDoc, "output")
}
}).catch(function(error) {
logger.warning("Could not load settings: " + error.toString() + "\n Creating new settings file...");
loadedSuccessfully = false;
return defaultSettings;
});
if(!loadedSuccessfully) updateSettings({});
function settingListLoadDefault() {
updateSettings({
fps:defaultSettings.fps,
width:defaultSettings.width,
stickDistance:defaultSettings.stickDistance,
stickMode2:defaultSettings.stickMode2
});
}
function updateSettings(optiones:{fps?:number, width?:number, stickDistance?:number, stickMode2?:boolean, log?:string, output?:string}) {
if(optiones.fps === undefined) {
optiones.fps = settingList.fps;
@@ -95,6 +85,15 @@ function updateSettings(optiones:{fps?:number, width?:number, stickDistance?:num
});
}
function settingListLoadDefault() {
updateSettings({
fps:defaultSettings.fps,
width:defaultSettings.width,
stickDistance:defaultSettings.stickDistance,
stickMode2:defaultSettings.stickMode2
});
}
export {
updateSettings,
settingListLoadDefault,

View File

@@ -44,7 +44,7 @@ function Menu({side}:{side:Side}) {
return (
<header>
<h1 id="main-headline">{(side == Side.Main)? "StickExporterTX" : "Settings"}</h1>
<h4 id="main-headline">{(side == Side.Main)? "StickExporterTX" : "Settings"}</h4>
<div id="blender-info">
<div id="blender-icon">
{blenderLoading? <BlenderLoadingSVG/> : <BlenderReadySVG/>}