mirror of
https://github.com/felixrieseberg/macintosh.js.git
synced 2024-12-27 11:29:33 +00:00
feat: Some help
This commit is contained in:
parent
2f291ab536
commit
118703356d
2
.gitignore
vendored
2
.gitignore
vendored
@ -89,6 +89,6 @@ typings/
|
||||
out/
|
||||
|
||||
# Custom stuff
|
||||
src/basilisk/user_data
|
||||
src/basilisk/user_files
|
||||
src/basilisk/disk
|
||||
|
||||
|
@ -1,5 +1,31 @@
|
||||
const isDevMode = true;
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { app } = require('electron');
|
||||
|
||||
const appDataPath = app.getPath('userData');
|
||||
const devFilePath = path.join(appDataPath, 'developer');
|
||||
|
||||
let isDevMode = true;
|
||||
|
||||
function getIsDevMode() {
|
||||
if (isDevMode !== undefined) {
|
||||
return isDevMode;
|
||||
}
|
||||
|
||||
return isDevMode = fs.existsSync(devFilePath);
|
||||
}
|
||||
|
||||
function setIsDevMode(set) {
|
||||
if (set && !getIsDevMode()) {
|
||||
fs.writeFileSync(devFilePath, `So you're a developer, huh? Neat! Welcome aboard!`);
|
||||
} else if (!set && getIsDevMode()) {
|
||||
fs.unlinkSync(devFilePath);
|
||||
}
|
||||
|
||||
isDevMode = set;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
isDevMode,
|
||||
getIsDevMode,
|
||||
setIsDevMode
|
||||
};
|
||||
|
@ -1,4 +1,5 @@
|
||||
const { ipcMain, app, BrowserWindow } = require("electron");
|
||||
const { setIsDevMode, getIsDevMode } = require("./devmode");
|
||||
|
||||
function registerIpcHandlers() {
|
||||
ipcMain.handle("quit", () => app.quit());
|
||||
@ -8,6 +9,12 @@ function registerIpcHandlers() {
|
||||
w.webContents.toggleDevTools()
|
||||
);
|
||||
});
|
||||
|
||||
ipcMain.handle("getIsDevMode", () => getIsDevMode());
|
||||
|
||||
ipcMain.handle("setIsDevMode", (event, set) => {
|
||||
setIsDevMode(set);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
@ -1,7 +1,7 @@
|
||||
const { app, BrowserWindow, shell } = require("electron");
|
||||
const path = require("path");
|
||||
|
||||
const { isDevMode } = require("./devmode");
|
||||
const { getIsDevMode } = require("./devmode");
|
||||
|
||||
const windowList = {};
|
||||
let mainWindow;
|
||||
@ -42,7 +42,7 @@ function handleNewWindow(event, url, frameName, disposition, options) {
|
||||
newWindow.setMenu(null);
|
||||
windowList[url] = newWindow;
|
||||
|
||||
if (isDevMode) {
|
||||
if (getIsDevMode()) {
|
||||
newWindow.webContents.toggleDevTools();
|
||||
}
|
||||
|
||||
@ -78,7 +78,7 @@ function createWindow() {
|
||||
// Ensure we create child windows with the correct settings
|
||||
mainWindow.webContents.on("new-window", handleNewWindow);
|
||||
|
||||
if (isDevMode) {
|
||||
if (getIsDevMode()) {
|
||||
mainWindow.webContents.toggleDevTools();
|
||||
}
|
||||
}
|
||||
|
50
src/renderer/help.html
Normal file
50
src/renderer/help.html
Normal file
@ -0,0 +1,50 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Help</title>
|
||||
<link rel="stylesheet" href="style/help.css">
|
||||
</head>
|
||||
<body>
|
||||
<h1>Help</h1>
|
||||
|
||||
<h2>Passing files into the machine</h2>
|
||||
|
||||
<p>
|
||||
<ul>
|
||||
<li>Open the folder "macintosh.js" in your <a href="#_" id="user_dir">user directory</a>.</li>
|
||||
<li>Put any files you want to use in your VM (virtual machine) into that folder.</li>
|
||||
<li>Restart the app.</li>
|
||||
<li>On the VM's (virtual machine) desktop, find the "Unix" volume and double-click to open it.</li>
|
||||
<li>Find the "macintosh.js" folder, which now contains all your files.</li>
|
||||
</ul>
|
||||
|
||||
Files will be copied over when you start your VM (virtual machine). They are not synchronized while the VM is running. However, any changes made to the "macintosh.js" folder in your VM will be saved to the corresponding folder in your home directory once you shut the VM down.
|
||||
</p>
|
||||
|
||||
<h2>Getting files out of machine</h2>
|
||||
|
||||
<p>
|
||||
<ul>
|
||||
<li>On the VM's (virtual machine) desktop, find the "Unix" volume and double-click to open it.</li>
|
||||
<li>Find the "macintosh.js" folder.</li>
|
||||
<li>Copy any files you want to move out of your VM into that folder.</li>
|
||||
<li>Shut the VM down. The app will now copy all files into <a href="#_" id="user_dir2">the "macintosh.js" folder in your user directory</a>.</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<h2>Developer Tools</h2>
|
||||
|
||||
<p>
|
||||
If you're curious, you can enable developer tools. They will automatically open when you start the app. Some transparency features
|
||||
will break. Restart the app for this change to take effect.
|
||||
|
||||
<button id="devtools">Enable developer tools</button>
|
||||
</p>
|
||||
|
||||
<script>
|
||||
require('./help.js')
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
35
src/renderer/help.js
Normal file
35
src/renderer/help.js
Normal file
@ -0,0 +1,35 @@
|
||||
const { shell, ipcRenderer } = require('electron');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const homedir = require('os').homedir();
|
||||
const macDir = path.join(homedir, 'macintosh.js');
|
||||
|
||||
let isDevTools;
|
||||
|
||||
// Setup dev mode
|
||||
function fetchIsDevTools() {
|
||||
ipcRenderer.invoke('getIsDevMode').then((result) => {
|
||||
isDevTools = result;
|
||||
|
||||
if (result) {
|
||||
devtools.innerHTML = 'Disable developer tools';
|
||||
} else {
|
||||
devtools.innerHTML = 'Enable developer tools';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
user_dir.onclick = user_dir2.onclick = () => {
|
||||
if (!fs.existsSync(macDir)) {
|
||||
fs.mkdirSync(macDir);
|
||||
}
|
||||
|
||||
shell.showItemInFolder(macDir);
|
||||
}
|
||||
|
||||
devtools.onclick = async () => {
|
||||
await ipcRenderer.invoke('setIsDevMode', !isDevTools);
|
||||
fetchIsDevTools();
|
||||
}
|
||||
|
||||
fetchIsDevTools();
|
@ -20,6 +20,7 @@
|
||||
<div class="clear">
|
||||
<a id="close" href="#">Quit</a>
|
||||
<a id="credits" href="#" onclick="window.open('credits.html')">Credits</a>
|
||||
<a id="help" href="#" onclick="window.open('help.html')">Help</a>
|
||||
<a id="devtools" href="#">Dev</a>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -16,6 +16,10 @@ body {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
* {
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #3366CC;
|
||||
}
|
||||
|
7
src/renderer/style/help.css
Normal file
7
src/renderer/style/help.css
Normal file
@ -0,0 +1,7 @@
|
||||
@import "base.css";
|
||||
|
||||
body {
|
||||
font-size: 16px;
|
||||
margin: 15px;
|
||||
text-align: left;
|
||||
}
|
@ -14,7 +14,6 @@ const {
|
||||
AUDIO_DATA_BUFFER_SIZE,
|
||||
} = require("./audio");
|
||||
const { quit } = require("./ipc");
|
||||
const { isDevMode } = require("../main/devmode");
|
||||
|
||||
let isWorkerRunning = false;
|
||||
let isWorkerSaving = false;
|
||||
@ -40,9 +39,7 @@ function handleDiskSaved() {
|
||||
isWorkerSaving = false;
|
||||
|
||||
// We're just gonna quit
|
||||
if (!isDevMode) {
|
||||
quit();
|
||||
}
|
||||
quit();
|
||||
}
|
||||
|
||||
async function handleWorkerShutdown() {
|
||||
|
Loading…
Reference in New Issue
Block a user