Skip to content

Commit

Permalink
Fix #15, major bug breaking big addon creations/uploads
Browse files Browse the repository at this point in the history
  • Loading branch information
Leeous committed Oct 19, 2020
1 parent 99a298c commit 972815e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 20 deletions.
33 changes: 20 additions & 13 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,17 +170,21 @@ ipcMain.on('createJsonFile', (event, json, dir) => {
// This is ran once the client requests to create an addon
ipcMain.on('createGMAFile', (event, addonDir) => {
console.log("Addon's Directory: " + addonDir.toString());
sendConsoleData(["Addon's directory: " + addonDir.toString()]);
const gmad = spawn(settings.get('gmodDirectory') + '/bin/' + gmadFile, ['create', '-folder', addonDir]);
gmad.stdout.on('data', (data) => {
var arrayOfOutput = data.toString().split('\n');
if (data.includes('File list verification failed')) {
mainWindow.webContents.send("errorNote", "File list verification failed - check your addon for unallowed files.", true);
mainWindow.webContents.send("errorNote", "File list verification failed - check your addon for unallowed files.", false, true);
}
if (data.includes("Successfully")) {
var fixedArray = arrayOfOutput.slice(arrayOfOutput.length - 2, arrayOfOutput.length - 1);
fixedArray = fixedArray[0].match(/(?:"[^"]*"|^[^"]*$)/)[0].replace(/"/g, "");
var addonGMADir = fixedArray;
mainWindow.webContents.send('addonGMALocation', addonGMADir);
console.log("GMA location: " + addonGMADir);
sendConsoleData(arrayOfOutput);
}
var fixedArray = arrayOfOutput.slice(arrayOfOutput.length - 2, arrayOfOutput.length - 1)
fixedArray = fixedArray[0].match(/(?:"[^"]*"|^[^"]*$)/)[0].replace(/"/g, "")
var addonGMADir = fixedArray;
console.log("GMA location: " + addonGMADir);
mainWindow.webContents.send('addonGMALocation', addonGMADir);
});
});

Expand All @@ -202,19 +206,22 @@ ipcMain.on('uploadToWorkshop', (event, gmaDir, iconDir, addonId) => {
} else {
// Passes all the info needed to publish a Garry's Mod addon
const gmpublish = spawn(settings.get('gmodDirectory') + '/bin/' + gmpublishFile, ['create', '-icon', iconDir, '-addon', gmaDir]);
console.log(gmpublishFile, gmaDir, iconDir)
gmpublish.stdout.on('data', (data) => {
var arrayOfOutput = data.toString().split('\n');
sendConsoleData(arrayOfOutput)
if (data.includes('512x512')) {
mainWindow.webContents.send("errorNote", "Image must be a 512x512 baseline jpeg! Trying exporting with Paint.", true);
}
var fixedArray = arrayOfOutput.slice(arrayOfOutput.length - 2, arrayOfOutput.length - 1);
fixedArray = fixedArray[0].replace(/\D/, '');
fixedArray = fixedArray.substr(5, fixedArray.length);
var stringArray = fixedArray.toString()
var addonURLIndex = stringArray.indexOf("?id=")
var addonURL = stringArray.slice(addonURLIndex + 4, addonURLIndex + 14)
mainWindow.webContents.send('currentAddonID', addonURL);
if (data.includes("Addon creation finished")) {
var fixedArray = arrayOfOutput.slice(arrayOfOutput.length - 2, arrayOfOutput.length - 1);
fixedArray = fixedArray[0].replace(/\D/, '');
fixedArray = fixedArray.substr(5, fixedArray.length);
var stringArray = fixedArray.toString();
var addonURLIndex = stringArray.indexOf("?id=");
var addonURL = stringArray.slice(addonURLIndex + 4, addonURLIndex + 14)
mainWindow.webContents.send('currentAddonID', addonURL);
}
});
};
});
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ <h4>Creating GMA...</h4>
<img src="src/img/loading.gif" style="width: 64px; display: block; margin-left: auto; margin-right: auto; margin-top: 35px;" alt="">
</div>
<div id="uploading">
<p>Uploading to the workshop...</p>
<h4>Uploading to the workshop...</h4>
<img src="src/img/loading.gif" style="width: 64px; display: block; margin-left: auto; margin-right: auto; margin-top: 35px;" alt="">
</div>
<div id="newAddonLocation">
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gmod-addon-tool",
"version": "2.1.0",
"version": "2.2.0",
"description": "A simple tool to update Garry's Mod workshop addons.",
"main": "app.js",
"homepage": "https://leeous.com",
Expand Down
11 changes: 6 additions & 5 deletions src/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ addonToCreateData = {
"tags": [],
"ignore": []
};
currentAppVersion = "v2.1";
currentAppVersion = "v2.2";
let defaultMenuTitle = ""
let onlyCreate = null; // This tells us if the user is only wanting to create a GMA
let consoleData = new Array;
Expand Down Expand Up @@ -168,7 +168,6 @@ $(document).ready(() => {
// Let user select a GMA to extract
$("#gmaFileSelection").click(() => {
dialog.showOpenDialog(win, fileDialogOptions).then(r => {
let addonGMA = r.filePaths[0];
addonPath = r.filePaths[0];
if (addonGMA != null) {
ipcRenderer.send("checkIfDirectoryExists", addonGMA);
Expand Down Expand Up @@ -200,9 +199,9 @@ $(document).ready(() => {
if (!result.canceled) {
currentNewAddon = result.filePaths[0];
if (currentNewAddon != null) {
currentNewAddon = currentNewAddon.replace(/\\/g, "/");
ipcRenderer.send("checkIfDirectoryExists", currentNewAddon);
var n = currentNewAddon.lastIndexOf("\\");
console.log(n);
var n = currentNewAddon.lastIndexOf("/");
var result = currentNewAddon.substring(n + 1);
$("#addonDir b").text(result);
$("#addonDirCheck").css("background-color", "#56bd56");
Expand All @@ -219,6 +218,7 @@ $(document).ready(() => {
$("#addon_icon").click(() => {
dialog.showOpenDialog(win, imgDialogOptions).then(result => {
addonIcon = result.filePaths[0];
addonIcon = addonIcon.replace(/\\/g, "/");
if (addonIcon != null) {
ipcRenderer.send("checkIfDirectoryExists", addonIcon);
}
Expand Down Expand Up @@ -567,7 +567,8 @@ $(document).ready(() => {
function resetAddonCreation() {
jsonCheckboxCount = 0;
onlyCreate = null;
jsonExists =null
jsonExists = null;
addonPath = null;

// Clear the old data we used to make addon.json
addonToCreateData = {
Expand Down

0 comments on commit 972815e

Please sign in to comment.