mirror of
https://github.com/LinoSchmidt/StickExporterTX.git
synced 2026-03-21 01:51:15 +01:00
New Top Bar design
This commit is contained in:
@@ -1,16 +1,17 @@
|
|||||||
import {spawn} from 'child_process';
|
import {spawn} from 'child_process';
|
||||||
import logger from './logger';
|
import logger from './logger';
|
||||||
|
import { Platform, platform } from './platform';
|
||||||
|
|
||||||
export default function openFolder(path:string) {
|
export default function openFolder(path:string) {
|
||||||
if (process.platform === 'darwin') {
|
if (platform === Platform.Mac) {
|
||||||
spawn('open', [path]).on('error', (err) => {
|
spawn('open', [path]).on('error', (err) => {
|
||||||
logger.errorMSG(err.message);
|
logger.errorMSG(err.message);
|
||||||
});
|
});
|
||||||
} else if (process.platform === 'win32') {
|
} else if (platform === Platform.Windows) {
|
||||||
spawn('explorer', [path]).on('error', (err) => {
|
spawn('explorer', [path]).on('error', (err) => {
|
||||||
logger.errorMSG(err.message);
|
logger.errorMSG(err.message);
|
||||||
});
|
});
|
||||||
} else if (process.platform === 'linux') {
|
} else if (platform === Platform.Linux) {
|
||||||
spawn('xdg-open', [path]).on('error', (err) => {
|
spawn('xdg-open', [path]).on('error', (err) => {
|
||||||
logger.errorMSG(err.message);
|
logger.errorMSG(err.message);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
import {app} from '@electron/remote';
|
import {app} from '@electron/remote';
|
||||||
|
import { platformFolder, platform, Platform } from './platform';
|
||||||
|
|
||||||
export const dataPath = app.getPath('userData');
|
export const dataPath = app.getPath('userData');
|
||||||
export const appPath = app.getAppPath().replace("app.asar", "");
|
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");
|
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() {
|
export function platformCharacter() {
|
||||||
let platformCharacterTEMP = "/";
|
let platformCharacterTEMP = "/";
|
||||||
if (process.platform === "win32") {
|
if (platform === Platform.Windows) {
|
||||||
platformCharacterTEMP = "\\";
|
platformCharacterTEMP = "\\";
|
||||||
}
|
}
|
||||||
return platformCharacterTEMP;
|
return platformCharacterTEMP;
|
||||||
|
|||||||
15
src/components/platform.ts
Normal file
15
src/components/platform.ts
Normal 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
|
||||||
|
}
|
||||||
@@ -16,13 +16,14 @@ const defaultSettings = {
|
|||||||
output: defaultOutputPath
|
output: defaultOutputPath
|
||||||
}
|
}
|
||||||
|
|
||||||
let loadedSuccessfully = true;
|
let loadedSuccessfully = false;
|
||||||
const settingList = await fetch(SettingPath).then(function(response) {
|
const settingList = await fetch(SettingPath).then(function(response) {
|
||||||
return response.text();
|
return response.text();
|
||||||
}).then(function(data) {
|
}).then(function(data) {
|
||||||
const parser = new DOMParser();
|
const parser = new DOMParser();
|
||||||
const xmlDoc = parser.parseFromString(data, 'text/xml');
|
const xmlDoc = parser.parseFromString(data, 'text/xml');
|
||||||
|
|
||||||
|
loadedSuccessfully = true;
|
||||||
return {
|
return {
|
||||||
fps: parseInt(getXMLChild(xmlDoc, "fps")),
|
fps: parseInt(getXMLChild(xmlDoc, "fps")),
|
||||||
width: parseInt(getXMLChild(xmlDoc, "width")),
|
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"),
|
log: (getXMLChild(xmlDoc, "log") === "None")? "":getXMLChild(xmlDoc, "log"),
|
||||||
output: getXMLChild(xmlDoc, "output")
|
output: getXMLChild(xmlDoc, "output")
|
||||||
}
|
}
|
||||||
|
|
||||||
}).catch(function(error) {
|
}).catch(function(error) {
|
||||||
logger.warning("Could not load settings: " + error.toString() + "\n Creating new settings file...");
|
logger.warning("Could not load settings: " + error.toString() + "\n Creating new settings file...");
|
||||||
loadedSuccessfully = false;
|
|
||||||
return defaultSettings;
|
return defaultSettings;
|
||||||
});
|
});
|
||||||
if(!loadedSuccessfully) updateSettings({});
|
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}) {
|
function updateSettings(optiones:{fps?:number, width?:number, stickDistance?:number, stickMode2?:boolean, log?:string, output?:string}) {
|
||||||
if(optiones.fps === undefined) {
|
if(optiones.fps === undefined) {
|
||||||
optiones.fps = settingList.fps;
|
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 {
|
export {
|
||||||
updateSettings,
|
updateSettings,
|
||||||
settingListLoadDefault,
|
settingListLoadDefault,
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ function Menu({side}:{side:Side}) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<header>
|
<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-info">
|
||||||
<div id="blender-icon">
|
<div id="blender-icon">
|
||||||
{blenderLoading? <BlenderLoadingSVG/> : <BlenderReadySVG/>}
|
{blenderLoading? <BlenderLoadingSVG/> : <BlenderReadySVG/>}
|
||||||
|
|||||||
@@ -20,13 +20,15 @@ header {
|
|||||||
display: flex;
|
display: flex;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 20px 25px;
|
padding: 0px 5px;
|
||||||
|
padding-right: 142px;
|
||||||
background-color: #0d131e;
|
background-color: #0d131e;
|
||||||
height: 20px;
|
height: 31px;
|
||||||
color: #9DA8B9;
|
color: #9DA8B9;
|
||||||
margin-bottom: 25px;
|
margin-bottom: 25px;
|
||||||
|
-webkit-app-region: drag;
|
||||||
}
|
}
|
||||||
header h1 {
|
header h4 {
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
display: flex;
|
display: flex;
|
||||||
width: auto;
|
width: auto;
|
||||||
@@ -34,23 +36,27 @@ header h1 {
|
|||||||
|
|
||||||
.back-button {
|
.back-button {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
padding: 10px;
|
-webkit-app-region: no-drag;
|
||||||
|
padding: 6px 10px;
|
||||||
|
height: 100%;
|
||||||
background-color: #2196F3;
|
background-color: #2196F3;
|
||||||
color: white;
|
color: white;
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: 20px;
|
border-radius: 15px;
|
||||||
display: flex;
|
|
||||||
font-size: large;
|
font-size: large;
|
||||||
}
|
}
|
||||||
|
|
||||||
.back-button:hover {
|
.back-button:hover {
|
||||||
transform: scale(1.05);
|
background-color: #0b6ab9;
|
||||||
text-decoration: none;
|
transform: scale(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#stopRender {
|
#stopRender {
|
||||||
background-color: #e1334e;
|
background-color: #e1334e;
|
||||||
}
|
}
|
||||||
|
#stopRender:hover {
|
||||||
|
background-color: red;
|
||||||
|
}
|
||||||
|
|
||||||
#content {
|
#content {
|
||||||
padding-left: 25px;
|
padding-left: 25px;
|
||||||
@@ -59,64 +65,44 @@ header h1 {
|
|||||||
|
|
||||||
#settings-button {
|
#settings-button {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
-webkit-app-region: no-drag;
|
||||||
background-color: #2196F3;
|
background-color: #2196F3;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
width: 45px;
|
width: 30px;
|
||||||
height: 45px;
|
height: 30px;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
border: none;
|
border: none;
|
||||||
outline: none;
|
outline: none;
|
||||||
}
|
}
|
||||||
#settings-button svg {
|
#settings-button svg {
|
||||||
width: 35px;
|
height: 24px;
|
||||||
height: 35px;
|
|
||||||
fill: white;
|
fill: white;
|
||||||
margin-left: 5px;
|
margin-left: 3px;
|
||||||
margin-top: 5px;
|
margin-top: 3px;
|
||||||
}
|
}
|
||||||
#settings-button:hover {
|
#settings-button:hover {
|
||||||
transform: scale(1.05);
|
background-color: #0b6ab9;
|
||||||
}
|
transform: scale(1);
|
||||||
|
|
||||||
#update-available {
|
|
||||||
cursor: pointer;
|
|
||||||
background-color: #21f3ad;
|
|
||||||
border-radius: 20%;
|
|
||||||
width: 45px;
|
|
||||||
height: 45px;
|
|
||||||
align-items: center;
|
|
||||||
border: none;
|
|
||||||
outline: none;
|
|
||||||
margin-right: 15px;
|
|
||||||
}
|
|
||||||
#update-available svg {
|
|
||||||
width: 35px;
|
|
||||||
height: 35px;
|
|
||||||
fill: white;
|
|
||||||
margin-left: 5px;
|
|
||||||
margin-top: 5px;
|
|
||||||
}
|
|
||||||
#update-available:hover {
|
|
||||||
transform: scale(1.05);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#blender-info {
|
#blender-info {
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
}
|
}
|
||||||
#blender-info p {
|
#blender-info p {
|
||||||
margin-top: 5px;
|
padding-left: 5px;
|
||||||
margin-bottom: 0;
|
|
||||||
}
|
}
|
||||||
#blender-icon {
|
#blender-icon {
|
||||||
width: 25px;
|
width: 20px;
|
||||||
height: 25px;
|
height: 20px;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
}
|
}
|
||||||
#blender-icon svg {
|
#blender-icon svg {
|
||||||
width: 25px;
|
width: 20px;
|
||||||
height: 25px;
|
height: 20px;
|
||||||
fill: white;
|
fill: white;
|
||||||
}
|
}
|
||||||
#blender-loading-icon {
|
#blender-loading-icon {
|
||||||
|
|||||||
14
src/index.ts
14
src/index.ts
@@ -3,6 +3,7 @@ import {initialize as remoteInitialize, enable as remoteEnable} from '@electron/
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { autoUpdater } from "electron-updater";
|
import { autoUpdater } from "electron-updater";
|
||||||
import logger from 'electron-log';
|
import logger from 'electron-log';
|
||||||
|
import { Platform, platform } from './components/platform';
|
||||||
|
|
||||||
logger.transports.console.format = "{h}:{i}:{s} {text}";
|
logger.transports.console.format = "{h}:{i}:{s} {text}";
|
||||||
logger.transports.file.getFile();
|
logger.transports.file.getFile();
|
||||||
@@ -63,20 +64,21 @@ const createWindow = () => {
|
|||||||
webPreferences: {
|
webPreferences: {
|
||||||
nodeIntegration: true,
|
nodeIntegration: true,
|
||||||
contextIsolation: false,
|
contextIsolation: false,
|
||||||
|
},
|
||||||
|
titleBarStyle: 'hidden',
|
||||||
|
titleBarOverlay: {
|
||||||
|
color: '#0d131e',
|
||||||
|
symbolColor: '#74b1be'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// remove the menu bar when in production.
|
mainWindow.setMenu(null);
|
||||||
if(process.env.NODE_ENV === 'production') mainWindow.setMenu(null);
|
|
||||||
|
|
||||||
remoteInitialize();
|
remoteInitialize();
|
||||||
remoteEnable(mainWindow.webContents);
|
remoteEnable(mainWindow.webContents);
|
||||||
|
|
||||||
// load the index.html of the app.
|
// load the index.html of the app.
|
||||||
mainWindow.loadFile(path.join(__dirname, 'index.html'));
|
mainWindow.loadFile(path.join(__dirname, 'index.html'));
|
||||||
|
|
||||||
// Open the DevTools when in development mode.
|
|
||||||
if(process.env.NODE_ENV === 'development') mainWindow.webContents.openDevTools();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// This method will be called when Electron has finished
|
// This method will be called when Electron has finished
|
||||||
@@ -88,7 +90,7 @@ app.on('ready', createWindow);
|
|||||||
// for applications and their menu bar to stay active until the user quits
|
// for applications and their menu bar to stay active until the user quits
|
||||||
// explicitly with Cmd + Q.
|
// explicitly with Cmd + Q.
|
||||||
app.on('window-all-closed', () => {
|
app.on('window-all-closed', () => {
|
||||||
if (process.platform !== 'darwin') {
|
if (platform !== Platform.Mac) {
|
||||||
app.quit();
|
app.quit();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user