mirror of
https://github.com/felixrieseberg/macintosh.js.git
synced 2025-01-13 02:29:50 +00:00
Update Electron
This commit is contained in:
parent
e5b24cc04a
commit
05136c28c1
16
package.json
16
package.json
@ -10,7 +10,7 @@
|
||||
"make": "electron-forge make",
|
||||
"publish": "electron-forge publish",
|
||||
"lint": "npx prettier --check src/{main,renderer}/*.{js,css} && npm run check-links",
|
||||
"fix": "npx prettier --write src/{main,renderer}/*.{js,css}",
|
||||
"fix": "npx prettier --write \"src/{main,renderer}/**.{js,css}\"",
|
||||
"check-links": "node tools/check-links.js"
|
||||
},
|
||||
"keywords": [],
|
||||
@ -27,12 +27,12 @@
|
||||
"update-electron-app": "^2.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@electron-forge/cli": "6.0.0-beta.54",
|
||||
"@electron-forge/maker-deb": "6.0.0-beta.54",
|
||||
"@electron-forge/maker-rpm": "6.0.0-beta.54",
|
||||
"@electron-forge/maker-squirrel": "6.0.0-beta.54",
|
||||
"@electron-forge/maker-zip": "6.0.0-beta.54",
|
||||
"electron": "11.1.1",
|
||||
"@electron-forge/cli": "6.0.5",
|
||||
"@electron-forge/maker-deb": "6.0.5",
|
||||
"@electron-forge/maker-rpm": "6.0.5",
|
||||
"@electron-forge/maker-squirrel": "6.0.5",
|
||||
"@electron-forge/maker-zip": "6.0.5",
|
||||
"electron": "23.1.3",
|
||||
"node-fetch": "^2.6.1"
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
const { app, dialog } = require("electron");
|
||||
const { getIsDevMode } = require("./devmode");
|
||||
|
||||
// If the app doesn't run from the /Applications folder,
|
||||
// we don't get to create files, which keeps the emulator from
|
||||
@ -8,6 +9,10 @@ function moveToAppFolderMaybe() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (getIsDevMode()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (app.isInApplicationsFolder()) {
|
||||
return;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
const { app, BrowserWindow, shell } = require("electron");
|
||||
const { BrowserWindow, shell } = require("electron");
|
||||
const path = require("path");
|
||||
|
||||
const { getIsDevMode } = require("./devmode");
|
||||
@ -66,13 +66,26 @@ function createWindow() {
|
||||
resizable: true,
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
nodeIntegrationInWorker: true,
|
||||
nativeWindowOpen: true,
|
||||
contextIsolation: false,
|
||||
navigateOnDragDrop: false,
|
||||
nodeIntegrationInWorker: true,
|
||||
sandbox: false,
|
||||
},
|
||||
});
|
||||
|
||||
// Ensure that we have access to SharedArrayBuffer
|
||||
mainWindow.webContents.session.webRequest.onHeadersReceived(
|
||||
(details, callback) => {
|
||||
details.responseHeaders["Cross-Origin-Opener-Policy"] = ["same-origin"];
|
||||
details.responseHeaders["Cross-Origin-Embedder-Policy"] = [
|
||||
"require-corp",
|
||||
];
|
||||
callback({ responseHeaders: details.responseHeaders });
|
||||
}
|
||||
);
|
||||
|
||||
// and load the index.html of the app.
|
||||
mainWindow.loadFile(path.join(__dirname, "../renderer/index.html"));
|
||||
|
||||
@ -89,5 +102,5 @@ function createWindow() {
|
||||
|
||||
module.exports = {
|
||||
createWindow,
|
||||
getMainWindow
|
||||
getMainWindow,
|
||||
};
|
||||
|
@ -1,29 +1,29 @@
|
||||
const { videoModeBufferView } = require("./video");
|
||||
var SCREEN_WIDTH = 800;
|
||||
var SCREEN_HEIGHT = 600;
|
||||
const BITS = 4;
|
||||
const SCREEN_BUFFER_SIZE = 800 * 600 * BITS; // 32bpp;
|
||||
|
||||
|
||||
const screenBuffer = new SharedArrayBuffer(SCREEN_BUFFER_SIZE);
|
||||
const screenBufferView = new Uint8Array(screenBuffer);
|
||||
|
||||
canvas.width = SCREEN_WIDTH;
|
||||
canvas.height = SCREEN_HEIGHT;
|
||||
let screenWidth = 800;
|
||||
let screenHeight = 600;
|
||||
|
||||
canvas.width = screenWidth;
|
||||
canvas.height = screenHeight;
|
||||
|
||||
const canvasCtx = canvas.getContext("2d");
|
||||
var imageData = canvasCtx.createImageData(SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||
let imageData = canvasCtx.createImageData(screenWidth, screenHeight);
|
||||
|
||||
window.addEventListener('resize', () => {
|
||||
SCREEN_HEIGHT = window.innerHeight -35;
|
||||
SCREEN_WIDTH = Math.floor(SCREEN_HEIGHT * (4 / 3))
|
||||
if(window.innerWidth < SCREEN_WIDTH){
|
||||
SCREEN_WIDTH = window.innerWidth;
|
||||
SCREEN_HEIGHT = Math.floor(SCREEN_WIDTH * 0.75);
|
||||
window.addEventListener("resize", () => {
|
||||
screenHeight = window.innerHeight - 35;
|
||||
screenWidth = Math.floor(screenHeight * (4 / 3));
|
||||
if (window.innerWidth < screenWidth) {
|
||||
screenWidth = window.innerWidth;
|
||||
screenHeight = Math.floor(screenWidth * 0.75);
|
||||
}
|
||||
canvas.width = SCREEN_WIDTH;
|
||||
canvas.height = SCREEN_HEIGHT;
|
||||
imageData = canvasCtx.createImageData(SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||
canvas.width = screenWidth;
|
||||
canvas.height = screenHeight;
|
||||
imageData = canvasCtx.createImageData(screenWidth, screenHeight);
|
||||
});
|
||||
|
||||
let stopDrawing = false;
|
||||
@ -31,11 +31,11 @@ let stopDrawing = false;
|
||||
function drawScreen() {
|
||||
if (stopDrawing) return;
|
||||
const pixelsRGBA = imageData.data;
|
||||
const numPixels = SCREEN_WIDTH * SCREEN_HEIGHT;
|
||||
const numPixels = screenWidth * screenHeight;
|
||||
const expandedFromPalettedMode = videoModeBufferView[3];
|
||||
|
||||
if (expandedFromPalettedMode) {
|
||||
for (var i = 0; i < numPixels; i++) {
|
||||
for (let i = 0; i < numPixels; i++) {
|
||||
// palette
|
||||
pixelsRGBA[i * BITS + 0] = screenBufferView[i * BITS + 0];
|
||||
pixelsRGBA[i * BITS + 1] = screenBufferView[i * BITS + 1];
|
||||
@ -43,17 +43,20 @@ function drawScreen() {
|
||||
pixelsRGBA[i * BITS + 3] = 255; // full opacity
|
||||
}
|
||||
} else {
|
||||
for (var i = 0; i < SCREEN_HEIGHT; i++) {
|
||||
for (var j = 0; j < SCREEN_WIDTH; j++){
|
||||
for (let i = 0; i < screenHeight; i++) {
|
||||
for (let j = 0; j < screenWidth; j++) {
|
||||
// ARGB
|
||||
const xRatio = 800 / SCREEN_WIDTH;
|
||||
const yRatio = 600 / SCREEN_HEIGHT;
|
||||
const xRatio = 800 / screenWidth;
|
||||
const yRatio = 600 / screenHeight;
|
||||
const px = Math.floor(j * xRatio);
|
||||
const py = Math.floor(i * yRatio);
|
||||
pixelsRGBA[((i * SCREEN_WIDTH) + j) * 4 + 0] = screenBufferView[((py*800) +px) * 4 + 1];//- lineMult];
|
||||
pixelsRGBA[((i * SCREEN_WIDTH) + j) * 4 + 1] = screenBufferView[((py*800) +px) * 4 + 2];//- lineMult];
|
||||
pixelsRGBA[((i * SCREEN_WIDTH) + j) * 4 + 2] = screenBufferView[((py*800) +px) * 4 + 3];//- lineMult];
|
||||
pixelsRGBA[((i * SCREEN_WIDTH) + j) * 4 + 3] = 255; // full opacity
|
||||
pixelsRGBA[(i * screenWidth + j) * 4 + 0] =
|
||||
screenBufferView[(py * 800 + px) * 4 + 1]; //- lineMult];
|
||||
pixelsRGBA[(i * screenWidth + j) * 4 + 1] =
|
||||
screenBufferView[(py * 800 + px) * 4 + 2]; //- lineMult];
|
||||
pixelsRGBA[(i * screenWidth + j) * 4 + 2] =
|
||||
screenBufferView[(py * 800 + px) * 4 + 3]; //- lineMult];
|
||||
pixelsRGBA[(i * screenWidth + j) * 4 + 3] = 255; // full opacity
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -86,7 +89,7 @@ module.exports = {
|
||||
screenBufferView,
|
||||
SCREEN_BUFFER_SIZE,
|
||||
drawScreen,
|
||||
SCREEN_WIDTH,
|
||||
SCREEN_HEIGHT,
|
||||
SCREEN_WIDTH: screenWidth,
|
||||
SCREEN_HEIGHT: screenHeight,
|
||||
setCanvasBlank,
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user