Skip to content

Commit

Permalink
close to release, various fixes and changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Leeous committed May 8, 2019
1 parent 100caff commit 012af2f
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 41 deletions.
7 changes: 3 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ <h3>What would you like to do?</h3>
<div class="top">
<button id="back_button_existing_addon" class="back_button" data-backwards="#addon_management_prompt" data-forwards="#update_existing_addon" data-resize="500, 175">◀ Back</button>
<h3>Your addons</h3>
<p id="refresh_addons"><a href="#">Refresh</a></p>
</div>
<div id="yourAddons"></div>
</div>
Expand Down Expand Up @@ -161,7 +160,7 @@ <h3>Addon creation</h3>
<div id="gmaPrep">
<!-- <p>Created <span style="font-weight: 700">addon.json</span>!</p> -->
<h3>Create GMA for uploading to the Workshop?</h3>
<button style="width: 100px;" class="button_normal transition_button" id="resetAddonCreation" data-divtohide="#create_new_addon" data-divtoshow="#addon_management_prompt" data-resize="500, 175">No</button>
<button style="width: 100px;" class="button_normal transition_button resetAddonCreation" data-divtohide="#create_new_addon" data-divtoshow="#addon_management_prompt" data-resize="500, 175">No</button>
<button style="width: 100px;" id="createGMAFile" class="button_normal transition_button">Yes</button>
<!-- <img src="src/img/loading.gif" style="display: block; margin-left: auto; margin-right: auto; width: 64px;" alt=""> -->
</div>
Expand All @@ -179,9 +178,9 @@ <h3>Upload to the Workshop?</h3>
<img src="src/img/loading.gif" style="width: 64px; display: block; margin-left: auto; margin-right: auto; margin-top: 35px;" alt="">
</div>
<div id="new_addon">
<p>Uploaded!</p>
<h3>Uploaded!</h3>
<p><a id="new_addon_link" style="color: white;" href="#">View on Steam</a></p>
<button class="button_normal" style="width: 100px;">Done</button>
<button class="button_normal transition_button resetAddonCreation" data-divtohide="#create_new_addon" data-divtoshow="#addon_management_prompt" data-resize="500, 175" style="width: 100px;">Done</button>
</div>
</div>
</div>
Expand Down
33 changes: 23 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,29 @@ ipcMain.on('createGMAFile', (event, addonDir) => {
});
});

ipcMain.on('uploadToWorkshop', (event, gmaDir, iconDir) => {
const gmpublish = spawn(settings.get('gmodDirectory') + '\\bin\\gmpublish.exe', ['create', '-icon', iconDir, '-addon', gmaDir]);
gmpublish.stdout.on('data', (data) => {
var arrayOfOutput = data.toString().split('\n')
var fixedArray = arrayOfOutput.slice(arrayOfOutput.length - 8, arrayOfOutput.length - 7)
fixedArray = fixedArray[0].replace(/\D/, '')
fixedArray = fixedArray.substr(5, fixedArray.length)
console.log(fixedArray)
mainWindow.webContents.send('currentAddonID', fixedArray);
})
ipcMain.on('uploadToWorkshop', (event, gmaDir, iconDir, addonId) => {
if (addonId != null) {
const gmpublish = spawn(settings.get('gmodDirectory') + '\\bin\\gmpublish.exe', ['update', '-id', addonId, '-icon', iconDir, '-addon', gmaDir]);
gmpublish.stdout.on('data', (data) => {
var arrayOfOutput = data.toString().split('\n')
var fixedArray = arrayOfOutput.slice(arrayOfOutput.length - 8, arrayOfOutput.length - 7)
fixedArray = fixedArray[0].replace(/\D/, '')
fixedArray = fixedArray.substr(5, fixedArray.length)
console.log(fixedArray)
mainWindow.webContents.send('currentAddonID', fixedArray);
});
} else {
const gmpublish = spawn(settings.get('gmodDirectory') + '\\bin\\gmpublish.exe', ['create', '-icon', iconDir, '-addon', gmaDir]);
gmpublish.stdout.on('data', (data) => {
var arrayOfOutput = data.toString().split('\n')
var fixedArray = arrayOfOutput.slice(arrayOfOutput.length - 8, arrayOfOutput.length - 7)
fixedArray = fixedArray[0].replace(/\D/, '')
fixedArray = fixedArray.substr(5, fixedArray.length)
console.log(fixedArray)
mainWindow.webContents.send('currentAddonID', fixedArray);
});
};

})


Expand Down
9 changes: 6 additions & 3 deletions src/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ header {

#update_existing_addon .top {
background-color: #0f0f0f;
padding: 5px 10px;
display: flex;
align-items: center;
}
Expand Down Expand Up @@ -257,15 +256,19 @@ header {
padding: 15px 0;
}

.addon_existing p {
margin: 0
.addon_existing .title {
margin: 0;
cursor: default;
}

.addon_link {
display: none;
margin-top: 5px;
margin-bottom: 0;
}

.addon_link a {
padding: 3px;
color: white;
}

Expand Down
56 changes: 32 additions & 24 deletions src/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jsonCheckboxCount = 0;
jsonChecks = [false, false];
apiError = 0;
addonGMADir = "";
existingAddonId = null;
var addonTitle;
var addonTags;
var addonType;
Expand Down Expand Up @@ -75,7 +76,6 @@ $(document).ready(() => {
}
}
// console.log(data.response);
var addon = data.response.publishedfiledetails["0"];
okToProcessAddonList = true;
$('#update_existing_addon_button').text('Update existing addon');
});
Expand Down Expand Up @@ -182,6 +182,7 @@ $(document).ready(() => {
$('#create_new_addon_button').click(() => {
$('#addon_management_prompt').fadeOut(() => {
win.setBounds({height: 250})

$('#create_new_addon, #addonDirPrompt').fadeIn()
})
})
Expand All @@ -190,6 +191,7 @@ $(document).ready(() => {
var target = event.target;
var divToGoBack = $(target).data('forwards');
var divToShow = $(target).data('backwards');
resetAddonCreation()
if ($(target).data('resize') != null) {
var resizeInfo = JSON.parse("[" + $(target).data('resize') + "]");
}
Expand All @@ -209,7 +211,7 @@ $(document).ready(() => {
})

$('.removeBackOption').click(() => {
$('#back_button_addon_creation').fadeOut();
// $('#back_button_addon_creation').fadeOut();
})

// General function for transitioning between div tags (with a shitty name)
Expand All @@ -225,24 +227,13 @@ $(document).ready(() => {
})
}

// Check if user needs to refresh their addons
// TODO: Hopefully I can remove this later on as it really isn't needed (except in the case of Steam being down)
$('#refresh_addons').click(() => {
console.log("Attempting to refresh addons...");
$('#yourAddons').children().remove();
getAddonInfoFromSteam();
populateAddonList();

});

// Get array of addon infomation and append their names to #yourAddons
// Get array of addon infomation and append their info to #yourAddons
function populateAddonList() {
// This check is done to make sure this only gets executed once
if (!donePopulatingAddonList) {
for (let i = 0; i < addon_data.length; i++) {
$('#yourAddons').append("<div class='addon_existing'><p>" + addon_data[i].title + "</p><p class='addon_link'><a href='steam://url/CommunityFilePage/" + addon_data[i].id + "'>View</a> <a href='#'>Update</a></p></div>");
$('#yourAddons').append("<div class='addon_existing'><p class='title'>" + addon_data[i].title + "</p><p class='addon_link'><a href='steam://url/CommunityFilePage/" + addon_data[i].id + "'>View</a> <a href='#' class='updateAddon' data-id='" + addon_data[i].id + "'>Update</a></p></div>");
donePopulatingAddonList = true;

}
// Make sure if nothing is returned to let the user know
// TODO: Allow for multiple error codes such as 429 (too many requests)
Expand Down Expand Up @@ -342,7 +333,7 @@ $(document).ready(() => {
}
}

$("#resetAddonCreation").click(() => {
$(".resetAddonCreation").click(() => {
resetAddonCreation();
});

Expand All @@ -366,40 +357,57 @@ $(document).ready(() => {
// Clear the addon name on directory selection
$("#addonDir b").text('');

// Set the input to null
// Set the file inputs to null
$("#addon_dir_folder").val(null);
$("#addon_icon").val(null);

// Reset directory validation
$('#addonDirCheck').css({backgroundColor: "#0f0f0f", cursor: "not-allowed"});
$('#addonDirCheck').prop('disabled', true);

// Reset icon validation
$('#addonIconCheck').css({backgroundColor: "#0f0f0f", cursor: "not-allowed"});
$('#addonIconCheck').prop('disabled', true);

// Reset validation checks
jsonChecks = [false, false];
validateJsonForm();

// Reset existingAddonId if user was updating instead of creating
existingAddonId = null;

// Hide any div that may still be displayed
$('#addonjsonPrompt, #jsonCreator, #gmaPrep, #createGMA').css('display', 'none');
$('#addonjsonPrompt, #addonIconPrompt, #jsonCreator, #gmaPrep, #createGMA, #new_addon, #uploading, #uploadToWorkshopPrompt').css('display', 'none');
}

$("#yourAddons").on('click', '.updateAddon', (event) => {
var target = event.target;
existingAddonId = $(target).data('id');
$("#update_existing_addon").fadeOut(() => {
$("#create_new_addon .top h3").text('Updating addon');
$("#create_new_addon, #addonDirPrompt").fadeIn();
});
});

$("#createGMAFile").click(() => {
$('#gmaPrep').fadeOut(() => {
win.setBounds({height: 225})
win.setBounds({height: 250});
$('#createGMA').fadeIn();
ipcRenderer.send('createGMAFile', currentNewAddon);
ipcRenderer.send('createGMAFile', currentNewAddon);
});
})
});

$("#uploadCurrentGMA").click(() => {
ipcRenderer.send('uploadToWorkshop', addonGMADir, addonIcon);
ipcRenderer.send('uploadToWorkshop', addonGMADir, addonIcon, existingAddonId);
$('#uploadToWorkshopPrompt').fadeOut(() => {
win.setBounds({height: 225})
win.setBounds({height: 250})
$('#uploading').fadeIn();
})
})

ipcRenderer.on('currentAddonID', (event, newAddonID) => {
$('#uploading').fadeOut(() => {
win.setBounds({height: 200})
win.setBounds({height: 225})
$('#new_addon_link').attr('href', 'steam://url/CommunityFilePage/' + newAddonID)
$('#new_addon').fadeIn()
});
Expand Down

0 comments on commit 012af2f

Please sign in to comment.