diff --git a/settings.html b/settings.html index 9804117..3386612 100644 --- a/settings.html +++ b/settings.html @@ -48,21 +48,9 @@
Where to get RGB matrix:
-
-
- - -
-
-
-
- - -
+
+ +
diff --git a/src/assets/index.css b/src/assets/index.css index a973817..4a1c905 100755 --- a/src/assets/index.css +++ b/src/assets/index.css @@ -185,6 +185,21 @@ div b.active.landable { border-bottom: 1px solid var(--main); } +form .btn { + color: inherit; + text-transform: inherit; + font-family: inherit; + font-size: inherit; + text-shadow: inherit; + border-radius: 0; + transition: color 400ms; +} + +form .btn:hover { + color: var(--main); + transition: color 400ms; +} + .draggable { -webkit-app-region: drag; -webkit-user-select: none; diff --git a/src/main.js b/src/main.js index 0171e1f..aafefd1 100755 --- a/src/main.js +++ b/src/main.js @@ -1,4 +1,4 @@ -const { app, BrowserWindow, Menu, ipcMain } = require('electron'); +const { app, BrowserWindow, Menu, ipcMain, dialog } = require('electron'); const path = require('path'); // Handle creating/removing shortcuts on Windows when installing/uninstalling. @@ -7,7 +7,6 @@ if (require('electron-squirrel-startup')) { } let mainWindow; -let settingsWindow; const createWindow = () => { // Create the browser window. @@ -68,6 +67,21 @@ const loadMain = (event) => { } } +// Set up file picker handler. +const selectMatrixFile = async () => { + const { canceled, filePaths } = await dialog.showOpenDialog(mainWindow, { + filters: [{name: 'Matrix File', extensions: ['xml', 'ini']}], + properties: ['openFile', 'showHiddenFiles'], + }); + + if (canceled) { + return; + } else { + return filePaths[0]; + } + +} + // This method will be called when Electron has finished // initialization and is ready to create browser windows. // Some APIs can only be used after this event occurs. @@ -75,6 +89,7 @@ app.on('ready', () => { ipcMain.on('CLOSE_WINDOW', closeWindow); ipcMain.on('LOAD_SETTINGS', loadSettings); ipcMain.on('LOAD_MAIN', loadMain); + ipcMain.handle('SELECT_MATRIX_FILE', selectMatrixFile); createWindow(); }); diff --git a/src/models/Settings.ts b/src/models/Settings.ts index 8ebfeb0..ffd5c78 100644 --- a/src/models/Settings.ts +++ b/src/models/Settings.ts @@ -3,6 +3,7 @@ const { statSync, writeFileSync, readFileSync } = require('node:fs'); const os = require('node:os'); const path = require('node:path'); +import { EliteMatrix } from "elite-matrix"; import { Log } from "./Log"; interface settingsFile { @@ -19,6 +20,9 @@ export class Settings { minValue: number; maxDistance: number; + #matrixFile?: string; + matrix?: EliteMatrix; + private constructor(isPackaged: boolean) { if (!isPackaged && os.platform() === 'linux') { this.#file = '/mnt/c/Users/marle/ed-safari-settings.json'; diff --git a/src/renderer.js b/src/renderer.js index e519a52..3822e3f 100755 --- a/src/renderer.js +++ b/src/renderer.js @@ -131,7 +131,6 @@ edsm.on('SYSTEM_APPRAISED', (system) => { } }); - // const matrixRed = [1.2, 0.05, 0.07]; // const matrixGreen = [0.13, 1, 1.18]; // const matrixBlue = [0.4, 1.29, 2]; diff --git a/src/settings.js b/src/settings.js index 5b4b4c3..b1fc068 100644 --- a/src/settings.js +++ b/src/settings.js @@ -28,6 +28,13 @@ $('.backBtn').on('click', () => { $('#minValue').attr('value', settings.minValue); $('#maxDistance').attr('value', settings.maxDistance); +/* ---------------------------------------------------------------------- select matrix file ---- */ + +$('#matrixBtn').on('click', async function () { + const filePath = await ipcRenderer.invoke('SELECT_MATRIX_FILE'); + $('#matrixFile').attr('value', filePath); +}); + /* ---------------------------------------------------------------------------- process form ---- */ $('form').on('submit', async function (event) {