Skip to content

Commit

Permalink
Update electron version. Fix nmrugg#24, potentially fix nmrugg#15 and…
Browse files Browse the repository at this point in the history
… introduce a workaround for nmrugg#21.
  • Loading branch information
aynurin committed May 27, 2022
1 parent 81170b0 commit 39adb1f
Show file tree
Hide file tree
Showing 5 changed files with 1,651 additions and 186 deletions.
16 changes: 12 additions & 4 deletions libs/epicApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -1095,13 +1095,21 @@ function addAssetToProject(assetInfo, projectData, ondone, onerror, onprogress)
return onerror(err);
}
versions = getItemVersions(assetInfo);

var version = null;

// If the right version is not found, ideally we need to let the user decide.
// While there is no dialog for that, we'll just take the first available version.
// Maybe choose the latest version using semver.
if (!versions[projectVersion]) {
return onerror("Version " + projectVersion + " is not avaiable.");
version = versions[Object.getOwnPropertyNames(versions)[0]];
console.warn("Version " + projectVersion + " is not avaiable. Available versions: " + Object.getOwnPropertyNames(versions).join(", ") + ". Will use " + version.version);
}
else {
version = versions[projectVersion];
}
///TODO: Skip getting build info if already extracted?
console.log("Getting build info...");
getItemBuildInfo(id, versions[projectVersion].appId, skipCache, function (err, itemBuildInfo, skipCache)
getItemBuildInfo(id, version.appId, skipCache, function (err, itemBuildInfo, skipCache)
{
console.log(skipCache);
if (err) {
Expand All @@ -1110,7 +1118,7 @@ function addAssetToProject(assetInfo, projectData, ondone, onerror, onprogress)
}
///TODO: Skip getting manifest if already extracted?
console.log("Getting item manifest...");
getItemManifest(id, versions[projectVersion].appId, itemBuildInfo, false, skipCache, function (err, manifest)
getItemManifest(id, version.appId, itemBuildInfo, false, skipCache, function (err, manifest)
{
var chunks;
var appId;
Expand Down
38 changes: 27 additions & 11 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ var fs = require("fs");
var request = require("./libs/request-helper.js");
var loadJsonFile = require("./libs/loadJsonFile.js");
var projectsManager = require("./libs/projects.js");
var electronRemote = require("@electron/remote/main");

var app = electron.app;
var BrowserWindow = electron.BrowserWindow;
var Menu = electron.Menu;
Expand All @@ -29,6 +31,8 @@ var configData;
var assetsData;
var localAssetsData;

electronRemote.initialize();

function mkdirSync(dir)
{
try {
Expand Down Expand Up @@ -276,7 +280,9 @@ function login(cb)


// Open the DevTools.
// loginWindow.webContents.openDevTools()
if (configData.devTools) {
loginWindow.webContents.openDevTools()
}

// Emitted when the window is closed.
/*
Expand Down Expand Up @@ -483,6 +489,7 @@ function sanitizeConfigWindowData()
function createMainWindow()
{
sanitizeConfigWindowData();
console.log("Running electron", process.versions.electron)
console.log(configData)

// Create the browser window.
Expand All @@ -495,6 +502,8 @@ function createMainWindow()
webPreferences: {
//preload: p.join(__dirname, "preload.js")
nodeIntegration: true,
contextIsolation: false,
enableRemoteModule: true,
devTools: configData.devTools,
},

Expand All @@ -503,6 +512,7 @@ function createMainWindow()
title: "Unreal Engine Launcher"
});
var contents = mainWindow.webContents;
electronRemote.enable(contents)
// and load the index.html of the app.
mainWindow.loadFile("pages/unreal_engine.html");

Expand Down Expand Up @@ -616,7 +626,8 @@ function downloadVaultData(cb)
}
///TODO: Try again?
}
cb(vault);
// This is an exceptional condition, so we cannot return the vault here
cb(null);
} else {
dlTotal = data.data.paging.total;

Expand Down Expand Up @@ -678,14 +689,13 @@ function updateVault(ignoreCache, cb)
{
if (data) {
vaultData = data;
} else {
vaultData = [];
// Only save a valid object. E.g., if the login was unsuccessful, we want to
// re-authenticate on the next run.
fs.writeFileSync(vaultPath, JSON.stringify(vaultData));
}

fs.writeFileSync(vaultPath, JSON.stringify(vaultData));

if (cb) {
cb(vaultData);
cb(data);
}
});
} else {
Expand Down Expand Up @@ -749,16 +759,20 @@ function getEngineVersion(path)
if (data.MajorVersion && data.MinorVersion) {
return data.MajorVersion + "." + data.MinorVersion;
}
} catch (e) {}
} catch (e) {
console.log(e);
}

try {
/// Check the last tag for the engine number.
data = require("child_process").execSync("git describe --abbrev=0", {stdio: "pipe", cwd: path, encoding: "utf8"}).trim();
match = data.match(/^(\d+\.\d+).*release$/);
match = data.match(/^(\d+\.\d+).*(?:release|early-access-\d+)$/);
if (match) {
return match[1];
}
} catch (e) {}
} catch (e) {
console.log(e);
}

try {
/// Check BRANCH_NAME in UE4Defines.pri for the engine number.
Expand All @@ -767,7 +781,9 @@ function getEngineVersion(path)
if (match) {
return match[1];
}
} catch (e) {}
} catch (e) {
console.log(e);
}

}

Expand Down
Loading

0 comments on commit 39adb1f

Please sign in to comment.